diff --git a/_infrastructure/tests/typescript/0.9.5-beta/lib.d.ts b/_infrastructure/tests/typescript/0.9.7/lib.d.ts similarity index 74% rename from _infrastructure/tests/typescript/0.9.5-beta/lib.d.ts rename to _infrastructure/tests/typescript/0.9.7/lib.d.ts index b0b5c96dd..94c477fd4 100644 --- a/_infrastructure/tests/typescript/0.9.5-beta/lib.d.ts +++ b/_infrastructure/tests/typescript/0.9.7/lib.d.ts @@ -70,7 +70,7 @@ 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. - */ + */ declare function encodeURI(uri: string): string; /** @@ -93,9 +93,12 @@ interface PropertyDescriptorMap { } interface Object { + /** The initial value of Object.prototype.constructor is the standard built-in Object constructor. */ + constructor: Function; + /** Returns a string representation of an object. */ toString(): string; - + /** Returns a date converted to a string using the current locale. */ toLocaleString(): string; @@ -368,7 +371,7 @@ interface String { * @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; + slice(start?: number, end?: number): string; /** * Split a string into substrings using the specified separator and return them as an array. @@ -461,7 +464,7 @@ interface Number { /** * 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; } @@ -522,7 +525,7 @@ interface Math { /** * 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. @@ -548,7 +551,7 @@ interface Math { /** * 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. @@ -581,7 +584,7 @@ interface Math { * @param y The exponent value of the expression. */ pow(x: number, y: number): number; - /** Returns a pseudorandom number between 0 and 1. */ + /** Returns a pseudorandom number between 0 and 1. */ random(): number; /** * Returns a supplied numeric expression rounded to the nearest number. @@ -663,44 +666,44 @@ interface Date { * 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): void; + 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. */ - setMilliseconds(ms: number): void; + 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. */ - setUTCMilliseconds(ms: number): void; + 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. */ - setSeconds(sec: number, ms?: number): void; + 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. */ - setUTCSeconds(sec: number, ms?: number): void; + 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. */ - setMinutes(min: number, sec?: number, ms?: number): void; + 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. */ - setUTCMinutes(min: number, sec?: number, ms?: number): void; + 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. @@ -708,7 +711,7 @@ interface Date { * @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): void; + 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. @@ -716,43 +719,43 @@ interface Date { * @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): void; + 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. */ - setDate(date: number): void; + 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. */ - setUTCDate(date: number): void; + 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. */ - setMonth(month: number, date?: number): void; + 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. */ - setUTCMonth(month: number, date?: number): void; + 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. */ - setFullYear(year: number, month?: number, date?: number): void; + 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. */ - setUTCFullYear(year: number, month?: number, date?: number): void; + setUTCFullYear(year: number, month?: number, date?: number): number; /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ toUTCString(): string; /** Returns a date as a string value in ISO format. */ @@ -802,7 +805,7 @@ interface RegExpExecArray { push(...items: string[]): number; reverse(): string[]; shift(): string; - slice(start: number, end?: number): string[]; + slice(start?: number, end?: number): string[]; sort(compareFn?: (a: string, b: string) => number): string[]; splice(start: number): string[]; splice(start: number, deleteCount: number, ...items: string[]): string[]; @@ -826,7 +829,7 @@ interface RegExp { * @param string The String object or string literal on which to perform the search. */ exec(string: string): RegExpExecArray; - + /** * 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. @@ -835,7 +838,7 @@ interface RegExp { /** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */ source: string; - + /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ global: boolean; @@ -1018,7 +1021,7 @@ interface 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): T[]; + slice(start?: number, end?: number): T[]; /** * Sorts an array. @@ -1129,7 +1132,7 @@ interface Array { [n: number]: T; } declare var Array: { - new(arrayLength?: number): any[]; + new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; (arrayLength?: number): any[]; @@ -1913,13 +1916,13 @@ interface String { } interface Number { - toLocaleString(locales: string[], options?: Intl.NumberFormatOptions): string; - toLocaleString(locale: string, options?: Intl.NumberFormatOptions): string; + toLocaleString(locales?: string[], options?: Intl.NumberFormatOptions): string; + toLocaleString(locale?: string, options?: Intl.NumberFormatOptions): string; } interface Date { - toLocaleString(locales: string[], options?: Intl.DateTimeFormatOptions): string; - toLocaleString(locale: string, options?: Intl.DateTimeFormatOptions): string; + toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; } @@ -3346,11 +3349,9 @@ declare var ControlRangeCollection: { interface MSNamespaceInfo extends MSEventAttachmentTarget { urn: string; onreadystatechange: (ev: Event) => any; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; name: string; readyState: string; doImport(implementationUrl: string): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } declare var MSNamespaceInfo: { prototype: MSNamespaceInfo; @@ -3484,149 +3485,89 @@ declare var SVGAnimatedLengthList: { interface Window extends EventTarget, MSEventAttachmentTarget, WindowLocalStorage, MSWindowExtensions, WindowSessionStorage, WindowTimers { ondragend: (ev: DragEvent) => any; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; onkeydown: (ev: KeyboardEvent) => any; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; ondragover: (ev: DragEvent) => any; - addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; onkeyup: (ev: KeyboardEvent) => any; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; onreset: (ev: Event) => any; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; onmouseup: (ev: MouseEvent) => any; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; ondragstart: (ev: DragEvent) => any; - addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; ondrag: (ev: DragEvent) => any; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; screenX: number; onmouseover: (ev: MouseEvent) => any; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; ondragleave: (ev: DragEvent) => any; - addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; history: History; pageXOffset: number; name: string; onafterprint: (ev: Event) => any; - addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; onpause: (ev: Event) => any; - addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; onbeforeprint: (ev: Event) => any; - addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; top: Window; onmousedown: (ev: MouseEvent) => any; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; onseeked: (ev: Event) => any; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; opener: Window; onclick: (ev: MouseEvent) => any; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; innerHeight: number; onwaiting: (ev: Event) => any; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; ononline: (ev: Event) => any; - addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; ondurationchange: (ev: Event) => any; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; frames: Window; onblur: (ev: FocusEvent) => any; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; onemptied: (ev: Event) => any; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; onseeking: (ev: Event) => any; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; oncanplay: (ev: Event) => any; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; outerWidth: number; onstalled: (ev: Event) => any; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; onmousemove: (ev: MouseEvent) => any; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; innerWidth: number; onoffline: (ev: Event) => any; - addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; length: number; screen: Screen; onbeforeunload: (ev: BeforeUnloadEvent) => any; - addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; onratechange: (ev: Event) => any; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; onstorage: (ev: StorageEvent) => any; - addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; onloadstart: (ev: Event) => any; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; ondragenter: (ev: DragEvent) => any; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; onsubmit: (ev: Event) => any; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; self: Window; document: Document; onprogress: (ev: any) => any; - addEventListener(type: "progress", listener: (ev: any) => any, useCapture?: boolean): void; ondblclick: (ev: MouseEvent) => any; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; pageYOffset: number; oncontextmenu: (ev: MouseEvent) => any; - addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; onchange: (ev: Event) => any; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; onloadedmetadata: (ev: Event) => any; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; onplay: (ev: Event) => any; - addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; onerror: ErrorEventHandler; onplaying: (ev: Event) => any; - addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; parent: Window; location: Location; oncanplaythrough: (ev: Event) => any; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; onabort: (ev: UIEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; onreadystatechange: (ev: Event) => any; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; outerHeight: number; onkeypress: (ev: KeyboardEvent) => any; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; frameElement: Element; onloadeddata: (ev: Event) => any; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; onsuspend: (ev: Event) => any; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; window: Window; onfocus: (ev: FocusEvent) => any; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; onmessage: (ev: MessageEvent) => any; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; ontimeupdate: (ev: Event) => any; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; onresize: (ev: UIEvent) => any; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; onselect: (ev: UIEvent) => any; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; navigator: Navigator; styleMedia: StyleMedia; ondrop: (ev: DragEvent) => any; - addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; onmouseout: (ev: MouseEvent) => any; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; onended: (ev: Event) => any; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; onhashchange: (ev: Event) => any; - addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; onunload: (ev: Event) => any; - addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; onscroll: (ev: UIEvent) => any; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; screenY: number; onmousewheel: (ev: MouseWheelEvent) => any; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; onvolumechange: (ev: Event) => any; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; oninput: (ev: Event) => any; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; performance: Performance; alert(message?: any): void; scroll(x?: number, y?: number): void; @@ -3644,7 +3585,6 @@ interface Window extends EventTarget, MSEventAttachmentTarget, WindowLocalStorag blur(): void; getSelection(): Selection; getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } declare var Window: { prototype: Window; @@ -3883,8 +3823,8 @@ declare var HTMLAreaElement: { } interface EventTarget { - removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; dispatchEvent(evt: Event): boolean; } @@ -4009,33 +3949,11 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document * @param ev The keyboard event */ onkeydown: (ev: KeyboardEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; /** * Fires when the user releases a key. * @param ev The keyboard event */ onkeyup: (ev: KeyboardEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; /** * Gets the implementation object of the current document. @@ -4046,17 +3964,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document * @param ev The event. */ onreset: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Retrieves a collection of all script objects in the document. @@ -4068,34 +3975,12 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document * @param ev The event. */ onhelp: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Fires on the target object when the user moves the mouse out of a valid drop target during a drag operation. * @param ev The drag event. */ ondragleave: (ev: DragEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; /** * Gets or sets the character set used to encode the object. @@ -4108,17 +3993,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onfocusin: (ev: FocusEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; /** * Sets or gets the color of the links that the user has visited. @@ -4131,17 +4005,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onseeked: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; security: string; /** @@ -4180,17 +4043,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ ondurationchange: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Returns a reference to the collection of elements contained by the object. @@ -4208,17 +4060,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onblur: (ev: FocusEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; /** * Sets or retrieves a value that indicates the reading order of the object. @@ -4231,17 +4072,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onemptied: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Sets or gets a value that indicates whether the document can be edited. @@ -4254,17 +4084,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onseeking: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Fires when the activeElement is changed from the current object to another object in the parent document. @@ -4272,17 +4091,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ ondeactivate: (ev: UIEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; /** * Occurs when playback is possible, but would require further buffering. @@ -4290,17 +4098,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ oncanplay: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Fires when the data set exposed by a data source object changes. @@ -4308,17 +4105,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ ondatasetchanged: (ev: MSEventObj) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; /** * Fires when rows are about to be deleted from the recordset. @@ -4326,17 +4112,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onrowsdelete: (ev: MSEventObj) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; Script: MSScriptHost; /** @@ -4345,17 +4120,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onloadstart: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Gets the URL for the document, stripped of any character encoding. @@ -4370,17 +4134,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ oncontrolselect: (ev: MSEventObj) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; /** * Fires on the target element when the user drags the object to a valid drop target. @@ -4388,29 +4141,7 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ ondragenter: (ev: DragEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; onsubmit: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Returns the character encoding used to create the webpage that is loaded into the document object. @@ -4428,17 +4159,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onchange: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Retrieves a collection of all a objects that specify the href property and all area objects in the document. @@ -4461,32 +4181,10 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onbeforeactivate: (ev: UIEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; head: HTMLHeadElement; cookie: string; xmlEncoding: string; oncanplaythrough: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Retrieves the document compatibility mode of the document. @@ -4501,17 +4199,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document anchors: HTMLCollection; onbeforeupdate: (ev: MSEventObj) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; /** * Fires to indicate that all data is available from the data source object. @@ -4519,17 +4206,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ ondatasetcomplete: (ev: MSEventObj) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; plugins: HTMLCollection; /** @@ -4538,17 +4214,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onsuspend: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Gets the root svg element in the document hierarchy. @@ -4576,17 +4241,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onerrorupdate: (ev: MSEventObj) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; /** * Gets a reference to the container object of the window. @@ -4599,17 +4253,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onmouseout: (ev: MouseEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; /** * Occurs when a user clicks a button in a Thumbnail Toolbar of a webpage running in Site Mode. @@ -4617,17 +4260,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onmsthumbnailclick: (ev: MSSiteModeEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "msthumbnailclick", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; /** * Fires when the wheel button is rotated. @@ -4635,17 +4267,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onmousewheel: (ev: MouseWheelEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; /** * Occurs when the volume is changed, or playback is muted or unmuted. @@ -4653,17 +4274,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onvolumechange: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Fires when data changes in the data provider. @@ -4671,17 +4281,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ oncellchange: (ev: MSEventObj) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; /** * Fires just before the data source control changes the current row in the object. @@ -4689,17 +4288,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onrowexit: (ev: MSEventObj) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; /** * Fires just after new rows are inserted in the current recordset. @@ -4707,17 +4295,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onrowsinserted: (ev: MSEventObj) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; /** * Gets or sets the version attribute specified in the declaration of an XML document. @@ -4732,17 +4309,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onpropertychange: (ev: MSEventObj) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; /** * Fires on the source object when the user releases the mouse at the close of a drag operation. @@ -4750,17 +4316,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ ondragend: (ev: DragEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; /** * Gets an object representing the document type declaration associated with the current document. @@ -4773,17 +4328,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ ondragover: (ev: DragEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; /** * Deprecated. Sets or retrieves a value that indicates the background color behind the object. @@ -4796,17 +4340,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ ondragstart: (ev: DragEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; /** * Fires when the user releases a mouse button while the mouse is over the object. @@ -4814,17 +4347,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onmouseup: (ev: MouseEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; /** * Fires on the source object continuously during a drag operation. @@ -4832,17 +4354,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ ondrag: (ev: DragEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; /** * Fires when the user moves the mouse pointer into the object. @@ -4850,17 +4361,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onmouseover: (ev: MouseEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; /** * Sets or gets the color of the document links. @@ -4873,17 +4373,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onpause: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Fires when the user clicks the object with either mouse button. @@ -4891,17 +4380,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onmousedown: (ev: MouseEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; /** * Fires when the user clicks the left mouse button on the object @@ -4909,17 +4387,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onclick: (ev: MouseEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; /** * Occurs when playback stops because the next frame of a video resource is not available. @@ -4927,17 +4394,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onwaiting: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Fires when the user clicks the Stop button or leaves the Web page. @@ -4946,16 +4402,8 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document onstop: (ev: Event) => any; /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. * false (false)[rolls - * Register the event handler for the bubbling phase. */ - addEventListener(type: "stop", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Occurs when an item is removed from a Jump List of a webpage running in Site Mode. @@ -4963,17 +4411,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onmssitemodejumplistitemremoved: (ev: MSSiteModeEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "mssitemodejumplistitemremoved", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; /** * Retrieves a collection of all applet objects in the document. @@ -5003,17 +4440,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onstalled: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Fires when the user moves the mouse over the object. @@ -5021,17 +4447,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onmousemove: (ev: MouseEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; /** * Gets a reference to the root node of the document. @@ -5044,17 +4459,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onbeforeeditfocus: (ev: MSEventObj) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; /** * Occurs when the playback rate is increased or decreased. @@ -5062,17 +4466,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onratechange: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Occurs to indicate progress while downloading media data. @@ -5080,17 +4473,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onprogress: (ev: any) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "progress", listener: (ev: any) => any, useCapture?: boolean): void; /** * Fires when the user double-clicks the object. @@ -5098,17 +4480,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ ondblclick: (ev: MouseEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; /** * Fires when the user clicks the right mouse button in the client area, opening the context menu. @@ -5116,17 +4487,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ oncontextmenu: (ev: MouseEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; /** * Occurs when the duration and dimensions of the media have been determined. @@ -5134,17 +4494,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onloadedmetadata: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; media: string; /** @@ -5153,17 +4502,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onerror: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Occurs when the play method is requested. @@ -5171,29 +4509,7 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onplay: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; onafterupdate: (ev: MSEventObj) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; /** * Occurs when the audio or video has started playing. @@ -5201,17 +4517,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onplaying: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Retrieves a collection, in source order, of img objects in the document. @@ -5229,17 +4534,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onabort: (ev: UIEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; /** * Fires for the current element with focus immediately after moving focus to another element. @@ -5247,17 +4541,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onfocusout: (ev: FocusEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; /** * Fires when the selection state of a document changes. @@ -5265,17 +4548,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onselectionchange: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "selectionchange", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Fires when a local DOM Storage area is written to disk. @@ -5283,17 +4555,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onstoragecommit: (ev: StorageEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "storagecommit", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; /** * Fires periodically as data arrives from data source objects that asynchronously transmit their data. @@ -5301,17 +4562,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ ondataavailable: (ev: MSEventObj) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; /** * Fires when the state of the object has changed. @@ -5319,17 +4569,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onreadystatechange: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Gets the date that the page was last modified, if the page supplies one. @@ -5342,17 +4581,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onkeypress: (ev: KeyboardEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; /** * Occurs when media data is loaded at the current playback position. @@ -5360,17 +4588,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onloadeddata: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Fires immediately before the activeElement is changed from the current object to another object in the parent document. @@ -5378,17 +4595,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onbeforedeactivate: (ev: UIEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; /** * Fires when the object is set as the active element. @@ -5396,30 +4602,8 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onactivate: (ev: UIEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; onselectstart: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Fires when the object receives focus. @@ -5427,17 +4611,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onfocus: (ev: FocusEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; /** * Sets or gets the foreground (text) color of the document. @@ -5450,17 +4623,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ ontimeupdate: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Fires when the current selection changes. @@ -5468,29 +4630,7 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onselect: (ev: UIEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; ondrop: (ev: DragEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; /** * Occurs when the end of playback is reached. @@ -5498,17 +4638,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onended: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Gets a value that indicates whether standards-compliant mode is switched on for the object. @@ -5521,17 +4650,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onscroll: (ev: UIEvent) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; /** * Fires to indicate that the current row has changed in the data source and new data values are available on the object. @@ -5539,17 +4657,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onrowenter: (ev: MSEventObj) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; /** * Fires immediately after the browser loads the object. @@ -5557,29 +4664,7 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document */ onload: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; oninput: (ev: Event) => any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event to register - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Returns the current value of the document, range, or current selection for the given command. @@ -6151,7 +5236,7 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document * @param tagName The name of an element. */ createElement(tagName: string): HTMLElement; - + /** * Removes mouse capture from the object in the current document. */ @@ -6750,7 +5835,7 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document * @param name Specifies the name of an element. */ getElementsByTagName(name: string): NodeList; - + /** * Creates a new document. */ @@ -6823,29 +5908,6 @@ interface Document extends Node, NodeSelector, MSEventAttachmentTarget, Document * @param elementId String that specifies the ID value. Case-insensitive. */ getElementById(elementId: string): HTMLElement; - - /** - * Registers an event handler for the specified event type. - * @param type The type of event type to register. - * @param listener The event handler function to associate with the event. - * @param useCapture Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: "DOMContentLoaded", listener: (ev: Event) => any, useCapture?: boolean): void; - /** - * Registers an event handler for the specified event type. - * @param type The type of event type to register. - * @param listener The event handler function to associate with the event. - * @param useCapture Boolean value that specifies the event phase to add the event handler for: - * true (true) - * Register the event handler for the capturing phase. - * false (false) - * Register the event handler for the bubbling phase. - */ - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } declare var Document: { @@ -6866,30 +5928,19 @@ declare var MessageEvent: { interface SVGElement extends Element { onmouseover: (ev: MouseEvent) => any; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; viewportElement: SVGElement; onmousemove: (ev: MouseEvent) => any; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; onmouseout: (ev: MouseEvent) => any; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; ondblclick: (ev: MouseEvent) => any; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; onfocusout: (ev: FocusEvent) => any; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; onfocusin: (ev: FocusEvent) => any; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; xmlbase: string; onmousedown: (ev: MouseEvent) => any; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; onmouseup: (ev: MouseEvent) => any; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; onclick: (ev: MouseEvent) => any; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; ownerSVGElement: SVGSVGElement; id: string; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } declare var SVGElement: { prototype: SVGElement; @@ -7173,18 +6224,10 @@ interface HTMLFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExt * Raised when the object has been completely received from the server. */ onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. */ security: any; - /** - * Registers an event handler for the specified event type. - * @param type The type of event type to register. - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for. If true, register the event handler for the capturing phase. If false, Register the event handler for the bubbling phase. - */ - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } declare var HTMLFrameElement: { prototype: HTMLFrameElement; @@ -7250,13 +6293,10 @@ interface XMLHttpRequest extends EventTarget { responseText: string; responseXML: Document; ontimeout: (ev: Event) => any; - addEventListener(type: "timeout", listener: (ev: Event) => any, useCapture?: boolean): void; statusText: string; onreadystatechange: (ev: Event) => any; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; timeout: number; onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; open(method: string, url: string, async?: boolean, user?: string, password?: string): void; create(): XMLHttpRequest; send(data?: any): void; @@ -7264,7 +6304,6 @@ interface XMLHttpRequest extends EventTarget { getAllResponseHeaders(): string; setRequestHeader(header: string, value: string): void; getResponseHeader(header: string): string; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; LOADING: number; DONE: number; UNSENT: number; @@ -7343,7 +6382,6 @@ interface SVGTransformable extends SVGLocatable { interface HTMLFrameSetElement extends HTMLElement { ononline: (ev: Event) => any; - addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Sets or retrieves the border color of the object. */ @@ -7360,7 +6398,6 @@ interface HTMLFrameSetElement extends HTMLElement { * Fires when the object loses the input focus. */ onblur: (ev: FocusEvent) => any; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; /** * Sets or retrieves the amount of additional space between the frames. */ @@ -7369,36 +6406,23 @@ interface HTMLFrameSetElement extends HTMLElement { * Fires when the object receives focus. */ onfocus: (ev: FocusEvent) => any; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; onmessage: (ev: MessageEvent) => any; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; onerror: (ev: Event) => any; - addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; /** * Sets or retrieves whether to display a border for the frame. */ frameBorder: string; onresize: (ev: UIEvent) => any; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; name: string; onafterprint: (ev: Event) => any; - addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; onbeforeprint: (ev: Event) => any; - addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; onoffline: (ev: Event) => any; - addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; border: string; onunload: (ev: Event) => any; - addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; onhashchange: (ev: Event) => any; - addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; onbeforeunload: (ev: BeforeUnloadEvent) => any; - addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; onstorage: (ev: StorageEvent) => any; - addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } declare var HTMLFrameSetElement: { prototype: HTMLFrameSetElement; @@ -7552,26 +6576,20 @@ interface SVGSVGElement extends SVGElement, SVGStylable, SVGZoomAndPan, Document x: SVGAnimatedLength; contentStyleType: string; onzoom: (ev: any) => any; - addEventListener(type: "zoom", listener: (ev: any) => any, useCapture?: boolean): void; y: SVGAnimatedLength; viewport: SVGRect; onerror: (ev: Event) => any; - addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; pixelUnitToMillimeterY: number; onresize: (ev: UIEvent) => any; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; screenPixelToMillimeterY: number; height: SVGAnimatedLength; onabort: (ev: UIEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; contentScriptType: string; pixelUnitToMillimeterX: number; currentTranslate: SVGPoint; onunload: (ev: Event) => any; - addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; currentScale: number; onscroll: (ev: UIEvent) => any; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; screenPixelToMillimeterX: number; setCurrentTime(seconds: number): void; createSVGLength(): SVGLength; @@ -7596,7 +6614,6 @@ interface SVGSVGElement extends SVGElement, SVGStylable, SVGZoomAndPan, Document createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; getElementById(elementId: string): Element; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } declare var SVGSVGElement: { prototype: SVGSVGElement; @@ -7816,14 +6833,6 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingEx * Raised when the object has been completely received from the server. */ onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - /** - * Registers an event handler for the specified event type. - * @param type The type of event type to register. - * @param listener The event handler function to associate with the event. - * @param useCapture A Boolean value that specifies the event phase to add the event handler for. If true, register the event handler for the capturing phase. If false, Register the event handler for the bubbling phase. - */ - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } declare var HTMLIFrameElement: { prototype: HTMLIFrameElement; @@ -7843,45 +6852,30 @@ declare var TextRangeCollection: { interface HTMLBodyElement extends HTMLElement, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { scroll: string; ononline: (ev: Event) => any; - addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; onblur: (ev: FocusEvent) => any; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; noWrap: boolean; onfocus: (ev: FocusEvent) => any; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; onmessage: (ev: MessageEvent) => any; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; text: any; onerror: (ev: Event) => any; - addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; bgProperties: string; onresize: (ev: UIEvent) => any; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; link: any; aLink: any; bottomMargin: any; topMargin: any; onafterprint: (ev: Event) => any; - addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; vLink: any; onbeforeprint: (ev: Event) => any; - addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; onoffline: (ev: Event) => any; - addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; onunload: (ev: Event) => any; - addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; onhashchange: (ev: Event) => any; - addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; rightMargin: any; onbeforeunload: (ev: BeforeUnloadEvent) => any; - addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; leftMargin: any; onstorage: (ev: StorageEvent) => any; - addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; createTextRange(): TextRange; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } declare var HTMLBodyElement: { prototype: HTMLBodyElement; @@ -8339,20 +7333,15 @@ declare var SVGStringList: { interface XDomainRequest { timeout: number; onerror: (ev: Event) => any; - addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; onprogress: (ev: any) => any; - addEventListener(type: "progress", listener: (ev: any) => any, useCapture?: boolean): void; ontimeout: (ev: Event) => any; - addEventListener(type: "timeout", listener: (ev: Event) => any, useCapture?: boolean): void; responseText: string; contentType: string; open(method: string, url: string): void; create(): XDomainRequest; abort(): void; send(data?: any): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } declare var XDomainRequest: { prototype: XDomainRequest; @@ -8545,6 +7534,7 @@ interface HTMLCanvasElement extends HTMLElement { * @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl"); */ getContext(contextId: "2d"): CanvasRenderingContext2D; + getContext(contextId: "experimental-webgl"): WebGLRenderingContext; getContext(contextId: string, ...args: any[]): any; } declare var HTMLCanvasElement: { @@ -8971,8 +7961,8 @@ declare var CSSImportRule: { } interface CustomEvent extends Event { - detail: Object; - initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: Object): void; + detail: any; + initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: any): void; } declare var CustomEvent: { prototype: CustomEvent; @@ -9093,7 +8083,6 @@ interface DOML2DeprecatedAlignmentStyle { interface HTMLMarqueeElement extends HTMLElement, MSDataBindingExtensions, DOML2DeprecatedBackgroundColorStyle { width: string; onbounce: (ev: Event) => any; - addEventListener(type: "bounce", listener: (ev: Event) => any, useCapture?: boolean): void; vspace: number; trueSpeed: boolean; scrollAmount: number; @@ -9104,12 +8093,9 @@ interface HTMLMarqueeElement extends HTMLElement, MSDataBindingExtensions, DOML2 direction: string; hspace: number; onstart: (ev: Event) => any; - addEventListener(type: "start", listener: (ev: Event) => any, useCapture?: boolean): void; onfinish: (ev: Event) => any; - addEventListener(type: "finish", listener: (ev: Event) => any, useCapture?: boolean): void; stop(): void; start(): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } declare var HTMLMarqueeElement: { prototype: HTMLMarqueeElement; @@ -9419,7 +8405,7 @@ declare var SVGRectElement: { interface ErrorEventHandler { (event: Event, source: string, fileno: number, columnNumber: number): void; - (message: any, uri: string, lineNumber: number, columnNumber?: number): boolean; + (message: any, uri: string, lineNumber: number, columnNumber?: number): void; } interface HTMLDivElement extends HTMLElement, MSDataBindingExtensions { @@ -9518,25 +8504,20 @@ declare var ProcessingInstruction: { interface MSWindowExtensions { status: string; onmouseleave: (ev: MouseEvent) => any; - addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; screenLeft: number; offscreenBuffering: any; maxConnectionsPerServer: number; onmouseenter: (ev: MouseEvent) => any; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; clipboardData: DataTransfer; defaultStatus: string; clientInformation: Navigator; closed: boolean; onhelp: (ev: Event) => any; - addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; external: External; event: MSEventObj; onfocusout: (ev: FocusEvent) => any; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; screenTop: number; onfocusin: (ev: FocusEvent) => any; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; showModelessDialog(url?: string, argument?: any, options?: any): Window; navigate(url: string): void; resizeBy(x?: number, y?: number): void; @@ -9549,7 +8530,6 @@ interface MSWindowExtensions { moveTo(x?: number, y?: number): void; moveBy(x?: number, y?: number): void; showHelp(url: string, helpArg?: any, features?: string): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } interface MSBehaviorUrnsCollection { @@ -10147,226 +9127,136 @@ declare var HTMLBGSoundElement: { interface HTMLElement extends Element, ElementCSSInlineStyle, MSEventAttachmentTarget, MSNodeExtensions { onmouseleave: (ev: MouseEvent) => any; - addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; onbeforecut: (ev: DragEvent) => any; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; onkeydown: (ev: KeyboardEvent) => any; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; onmove: (ev: MSEventObj) => any; - addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; onkeyup: (ev: KeyboardEvent) => any; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; onreset: (ev: Event) => any; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; onhelp: (ev: Event) => any; - addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; ondragleave: (ev: DragEvent) => any; - addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; className: string; onfocusin: (ev: FocusEvent) => any; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; onseeked: (ev: Event) => any; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; recordNumber: any; title: string; parentTextEdit: Element; outerHTML: string; ondurationchange: (ev: Event) => any; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; offsetHeight: number; all: HTMLCollection; onblur: (ev: FocusEvent) => any; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; dir: string; onemptied: (ev: Event) => any; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; onseeking: (ev: Event) => any; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; oncanplay: (ev: Event) => any; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; ondeactivate: (ev: UIEvent) => any; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; ondatasetchanged: (ev: MSEventObj) => any; - addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; onrowsdelete: (ev: MSEventObj) => any; - addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; sourceIndex: number; onloadstart: (ev: Event) => any; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; onlosecapture: (ev: MSEventObj) => any; - addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; ondragenter: (ev: DragEvent) => any; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; oncontrolselect: (ev: MSEventObj) => any; - addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; onsubmit: (ev: Event) => any; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; behaviorUrns: MSBehaviorUrnsCollection; scopeName: string; onchange: (ev: Event) => any; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; id: string; onlayoutcomplete: (ev: MSEventObj) => any; - addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; uniqueID: string; onbeforeactivate: (ev: UIEvent) => any; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; oncanplaythrough: (ev: Event) => any; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; onbeforeupdate: (ev: MSEventObj) => any; - addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; onfilterchange: (ev: MSEventObj) => any; - addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; offsetParent: Element; ondatasetcomplete: (ev: MSEventObj) => any; - addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; onsuspend: (ev: Event) => any; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; readyState: any; onmouseenter: (ev: MouseEvent) => any; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; innerText: string; onerrorupdate: (ev: MSEventObj) => any; - addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; onmouseout: (ev: MouseEvent) => any; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; parentElement: HTMLElement; onmousewheel: (ev: MouseWheelEvent) => any; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; onvolumechange: (ev: Event) => any; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; oncellchange: (ev: MSEventObj) => any; - addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; onrowexit: (ev: MSEventObj) => any; - addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; onrowsinserted: (ev: MSEventObj) => any; - addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; onpropertychange: (ev: MSEventObj) => any; - addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; filters: Object; children: HTMLCollection; ondragend: (ev: DragEvent) => any; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; onbeforepaste: (ev: DragEvent) => any; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; ondragover: (ev: DragEvent) => any; - addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; offsetTop: number; onmouseup: (ev: MouseEvent) => any; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; ondragstart: (ev: DragEvent) => any; - addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; onbeforecopy: (ev: DragEvent) => any; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; ondrag: (ev: DragEvent) => any; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; innerHTML: string; onmouseover: (ev: MouseEvent) => any; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; lang: string; uniqueNumber: number; onpause: (ev: Event) => any; - addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; tagUrn: string; onmousedown: (ev: MouseEvent) => any; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; onclick: (ev: MouseEvent) => any; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; onwaiting: (ev: Event) => any; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; onresizestart: (ev: MSEventObj) => any; - addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; offsetLeft: number; isTextEdit: boolean; isDisabled: boolean; onpaste: (ev: DragEvent) => any; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; canHaveHTML: boolean; onmoveend: (ev: MSEventObj) => any; - addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; language: string; onstalled: (ev: Event) => any; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; onmousemove: (ev: MouseEvent) => any; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; style: MSStyleCSSProperties; isContentEditable: boolean; onbeforeeditfocus: (ev: MSEventObj) => any; - addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; onratechange: (ev: Event) => any; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; contentEditable: string; tabIndex: number; document: Document; onprogress: (ev: any) => any; - addEventListener(type: "progress", listener: (ev: any) => any, useCapture?: boolean): void; ondblclick: (ev: MouseEvent) => any; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; oncontextmenu: (ev: MouseEvent) => any; - addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; onloadedmetadata: (ev: Event) => any; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; onafterupdate: (ev: MSEventObj) => any; - addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; onerror: (ev: Event) => any; - addEventListener(type: "error", listener: (ev: Event) => any, useCapture?: boolean): void; onplay: (ev: Event) => any; - addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; onresizeend: (ev: MSEventObj) => any; - addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; onplaying: (ev: Event) => any; - addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; isMultiLine: boolean; onfocusout: (ev: FocusEvent) => any; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; onabort: (ev: UIEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; ondataavailable: (ev: MSEventObj) => any; - addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; hideFocus: boolean; onreadystatechange: (ev: Event) => any; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; onkeypress: (ev: KeyboardEvent) => any; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; onloadeddata: (ev: Event) => any; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; onbeforedeactivate: (ev: UIEvent) => any; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; outerText: string; disabled: boolean; onactivate: (ev: UIEvent) => any; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; accessKey: string; onmovestart: (ev: MSEventObj) => any; - addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; onselectstart: (ev: Event) => any; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; onfocus: (ev: FocusEvent) => any; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; ontimeupdate: (ev: Event) => any; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; onresize: (ev: UIEvent) => any; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; oncut: (ev: DragEvent) => any; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; onselect: (ev: UIEvent) => any; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; ondrop: (ev: DragEvent) => any; - addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; offsetWidth: number; oncopy: (ev: DragEvent) => any; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; onended: (ev: Event) => any; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; onscroll: (ev: UIEvent) => any; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; onrowenter: (ev: MSEventObj) => any; - addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; onload: (ev: Event) => any; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; canHaveChildren: boolean; oninput: (ev: Event) => any; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; dragDrop(): boolean; scrollIntoView(top?: boolean): void; addFilter(filter: Object): void; @@ -10390,7 +9280,6 @@ interface HTMLElement extends Element, ElementCSSInlineStyle, MSEventAttachmentT applyElement(apply: Element, where?: string): Element; addBehavior(bstrUrl: string, factory?: any): number; insertAdjacentHTML(where: string, html: string): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } declare var HTMLElement: { prototype: HTMLElement; @@ -10911,149 +9800,89 @@ declare var Option: { new (text?: string, value?: string, defaultSelected?: bool declare var Image: { new (width?: number, height?: number): HTMLImageElement; }; declare var ondragend: (ev: DragEvent) => any; -declare function addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; declare var onkeydown: (ev: KeyboardEvent) => any; -declare function addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; declare var ondragover: (ev: DragEvent) => any; -declare function addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; declare var onkeyup: (ev: KeyboardEvent) => any; -declare function addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; declare var onreset: (ev: Event) => any; -declare function addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; declare var onmouseup: (ev: MouseEvent) => any; -declare function addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; declare var ondragstart: (ev: DragEvent) => any; -declare function addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; declare var ondrag: (ev: DragEvent) => any; -declare function addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; declare var screenX: number; declare var onmouseover: (ev: MouseEvent) => any; -declare function addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; declare var ondragleave: (ev: DragEvent) => any; -declare function addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; declare var history: History; declare var pageXOffset: number; declare var name: string; declare var onafterprint: (ev: Event) => any; -declare function addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; declare var onpause: (ev: Event) => any; -declare function addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; declare var onbeforeprint: (ev: Event) => any; -declare function addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; declare var top: Window; declare var onmousedown: (ev: MouseEvent) => any; -declare function addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; declare var onseeked: (ev: Event) => any; -declare function addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; declare var opener: Window; declare var onclick: (ev: MouseEvent) => any; -declare function addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; declare var innerHeight: number; declare var onwaiting: (ev: Event) => any; -declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare var ononline: (ev: Event) => any; -declare function addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; declare var ondurationchange: (ev: Event) => any; -declare function addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; declare var frames: Window; declare var onblur: (ev: FocusEvent) => any; -declare function addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; declare var onemptied: (ev: Event) => any; -declare function addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; declare var onseeking: (ev: Event) => any; -declare function addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; declare var oncanplay: (ev: Event) => any; -declare function addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; declare var outerWidth: number; declare var onstalled: (ev: Event) => any; -declare function addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; declare var onmousemove: (ev: MouseEvent) => any; -declare function addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; declare var innerWidth: number; declare var onoffline: (ev: Event) => any; -declare function addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; declare var length: number; declare var screen: Screen; declare var onbeforeunload: (ev: BeforeUnloadEvent) => any; -declare function addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; declare var onratechange: (ev: Event) => any; -declare function addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; declare var onstorage: (ev: StorageEvent) => any; -declare function addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; declare var onloadstart: (ev: Event) => any; -declare function addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; declare var ondragenter: (ev: DragEvent) => any; -declare function addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; declare var onsubmit: (ev: Event) => any; -declare function addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; declare var self: Window; declare var document: Document; declare var onprogress: (ev: any) => any; -declare function addEventListener(type: "progress", listener: (ev: any) => any, useCapture?: boolean): void; declare var ondblclick: (ev: MouseEvent) => any; -declare function addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; declare var pageYOffset: number; declare var oncontextmenu: (ev: MouseEvent) => any; -declare function addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; declare var onchange: (ev: Event) => any; -declare function addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; declare var onloadedmetadata: (ev: Event) => any; -declare function addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; declare var onplay: (ev: Event) => any; -declare function addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; declare var onerror: ErrorEventHandler; declare var onplaying: (ev: Event) => any; -declare function addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; declare var parent: Window; declare var location: Location; declare var oncanplaythrough: (ev: Event) => any; -declare function addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; declare var onabort: (ev: UIEvent) => any; -declare function addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; declare var onreadystatechange: (ev: Event) => any; -declare function addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; declare var outerHeight: number; declare var onkeypress: (ev: KeyboardEvent) => any; -declare function addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; declare var frameElement: Element; declare var onloadeddata: (ev: Event) => any; -declare function addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; declare var onsuspend: (ev: Event) => any; -declare function addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; declare var window: Window; declare var onfocus: (ev: FocusEvent) => any; -declare function addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; declare var onmessage: (ev: MessageEvent) => any; -declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; declare var ontimeupdate: (ev: Event) => any; -declare function addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; declare var onresize: (ev: UIEvent) => any; -declare function addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; declare var onselect: (ev: UIEvent) => any; -declare function addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; declare var navigator: Navigator; declare var styleMedia: StyleMedia; declare var ondrop: (ev: DragEvent) => any; -declare function addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; declare var onmouseout: (ev: MouseEvent) => any; -declare function addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; declare var onended: (ev: Event) => any; -declare function addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; declare var onhashchange: (ev: Event) => any; -declare function addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; declare var onunload: (ev: Event) => any; -declare function addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; declare var onscroll: (ev: UIEvent) => any; -declare function addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; declare var screenY: number; declare var onmousewheel: (ev: MouseWheelEvent) => any; -declare function addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; declare var onload: (ev: Event) => any; -declare function addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; declare var onvolumechange: (ev: Event) => any; -declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; declare var oninput: (ev: Event) => any; -declare function addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; declare var performance: Performance; declare function alert(message?: any): void; declare function scroll(x?: number, y?: number): void; @@ -11071,7 +9900,6 @@ declare function showModalDialog(url?: string, argument?: any, options?: any): a declare function blur(): void; declare function getSelection(): Selection; declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; -declare function addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; declare function removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; declare function dispatchEvent(evt: Event): boolean; declare function attachEvent(event: string, listener: EventListener): boolean; @@ -11079,25 +9907,20 @@ declare function detachEvent(event: string, listener: EventListener): void; declare var localStorage: Storage; declare var status: string; declare var onmouseleave: (ev: MouseEvent) => any; -declare function addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; declare var screenLeft: number; declare var offscreenBuffering: any; declare var maxConnectionsPerServer: number; declare var onmouseenter: (ev: MouseEvent) => any; -declare function addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; declare var clipboardData: DataTransfer; declare var defaultStatus: string; declare var clientInformation: Navigator; declare var closed: boolean; declare var onhelp: (ev: Event) => any; -declare function addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; declare var external: External; declare var event: MSEventObj; declare var onfocusout: (ev: FocusEvent) => any; -declare function addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; declare var screenTop: number; declare var onfocusin: (ev: FocusEvent) => any; -declare function addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; declare function showModelessDialog(url?: string, argument?: any, options?: any): Window; declare function navigate(url: string): void; declare function resizeBy(x?: number, y?: number): void; @@ -11122,14 +9945,12 @@ declare function setInterval(handler: any, timeout?: any, ...args: any[]): numbe ///////////////////////////// - interface ObjectURLOptions { oneTimeOnly?: boolean; } interface HTMLBodyElement { onpopstate: (ev: PopStateEvent) => any; - addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; } interface MSGestureEvent extends UIEvent { @@ -11158,8 +9979,6 @@ interface MSGestureEvent extends UIEvent { MSGESTURE_FLAG_NONE: number; } declare var MSGestureEvent: { - prototype: MSGestureEvent; - new (): MSGestureEvent; MSGESTURE_FLAG_BEGIN: number; MSGESTURE_FLAG_END: number; MSGESTURE_FLAG_CANCEL: number; @@ -11279,14 +10098,11 @@ interface HTMLInputElement { interface ErrorEvent extends Event { colno: number; filename: string; + error: any; lineno: number; message: string; initErrorEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, messageArg: string, filenameArg: string, linenoArg: number): void; } -declare var ErrorEvent: { - prototype: ErrorEvent; - new (): ErrorEvent; -} interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { y: SVGAnimatedLength; @@ -11299,33 +10115,17 @@ interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLan filterResY: SVGAnimatedInteger; setFilterRes(filterResX: number, filterResY: number): void; } -declare var SVGFilterElement: { - prototype: SVGFilterElement; - new (): SVGFilterElement; -} interface TrackEvent extends Event { track: any; } -declare var TrackEvent: { - prototype: TrackEvent; - new (): TrackEvent; -} interface SVGFEMergeNodeElement extends SVGElement { in1: SVGAnimatedString; } -declare var SVGFEMergeNodeElement: { - prototype: SVGFEMergeNodeElement; - new (): SVGFEMergeNodeElement; -} interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { } -declare var SVGFEFloodElement: { - prototype: SVGFEFloodElement; - new (): SVGFEFloodElement; -} interface MSGesture { target: Element; @@ -11339,7 +10139,6 @@ declare var MSGesture: { interface TextTrackCue extends EventTarget { onenter: (ev: Event) => any; - addEventListener(type: "enter", listener: (ev: Event) => any, useCapture?: boolean): void; track: TextTrack; endTime: number; text: string; @@ -11347,9 +10146,7 @@ interface TextTrackCue extends EventTarget { id: string; startTime: number; onexit: (ev: Event) => any; - addEventListener(type: "exit", listener: (ev: Event) => any, useCapture?: boolean): void; getCueAsHTML(): DocumentFragment; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } declare var TextTrackCue: { prototype: TextTrackCue; @@ -11378,10 +10175,6 @@ interface DOMTokenList { [index: number]: string; toString(): string; } -declare var DOMTokenList: { - prototype: DOMTokenList; - new (): DOMTokenList; -} interface EventException { name: string; @@ -11393,18 +10186,10 @@ interface Performance { interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { } -declare var SVGFEFuncAElement: { - prototype: SVGFEFuncAElement; - new (): SVGFEFuncAElement; -} interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { in1: SVGAnimatedString; } -declare var SVGFETileElement: { - prototype: SVGFETileElement; - new (): SVGFETileElement; -} interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { in2: SVGAnimatedString; @@ -11418,8 +10203,6 @@ interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttrib SVG_FEBLEND_MODE_LIGHTEN: number; } declare var SVGFEBlendElement: { - prototype: SVGFEBlendElement; - new (): SVGFEBlendElement; SVG_FEBLEND_MODE_DARKEN: number; SVG_FEBLEND_MODE_UNKNOWN: number; SVG_FEBLEND_MODE_MULTIPLY: number; @@ -11430,10 +10213,6 @@ declare var SVGFEBlendElement: { interface WindowTimers extends WindowTimersExtension { } -declare var WindowTimers: { - prototype: WindowTimers; - new (): WindowTimers; -} interface CSSStyleDeclaration { animationFillMode: string; @@ -11564,10 +10343,6 @@ declare var MessageChannel: { interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { } -declare var SVGFEMergeElement: { - prototype: SVGFEMergeElement; - new (): SVGFEMergeElement; -} interface Navigator extends MSFileSaver { msMaxTouchPoints: number; @@ -11581,10 +10356,6 @@ interface TransitionEvent extends Event { elapsedTime: number; initTransitionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, propertyNameArg: string, elapsedTimeArg: number): void; } -declare var TransitionEvent: { - prototype: TransitionEvent; - new (): TransitionEvent; -} interface MediaQueryList { matches: boolean; @@ -11592,19 +10363,11 @@ interface MediaQueryList { addListener(listener: MediaQueryListListener): void; removeListener(listener: MediaQueryListListener): void; } -declare var MediaQueryList: { - prototype: MediaQueryList; - new (): MediaQueryList; -} interface DOMError { name: string; toString(): string; } -declare var DOMError: { - prototype: DOMError; - new (): DOMError; -} interface CloseEvent extends Event { wasClean: boolean; @@ -11612,29 +10375,20 @@ interface CloseEvent extends Event { code: number; initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; } -declare var CloseEvent: { - prototype: CloseEvent; - new (): CloseEvent; -} interface WebSocket extends EventTarget { protocol: string; readyState: number; bufferedAmount: number; onopen: (ev: Event) => any; - addEventListener(type: "open", listener: (ev: Event) => any, useCapture?: boolean): void; extensions: string; onmessage: (ev: any) => any; - addEventListener(type: "message", listener: (ev: any) => any, useCapture?: boolean): void; onclose: (ev: CloseEvent) => any; - addEventListener(type: "close", listener: (ev: CloseEvent) => any, useCapture?: boolean): void; onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; binaryType: string; url: string; close(code?: number, reason?: string): void; send(data: any): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; OPEN: number; CLOSING: number; CONNECTING: number; @@ -11656,10 +10410,6 @@ interface SVGFEPointLightElement extends SVGElement { x: SVGAnimatedNumber; z: SVGAnimatedNumber; } -declare var SVGFEPointLightElement: { - prototype: SVGFEPointLightElement; - new (): SVGFEPointLightElement; -} interface ProgressEvent extends Event { loaded: number; @@ -11667,10 +10417,6 @@ interface ProgressEvent extends Event { total: number; initProgressEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, lengthComputableArg: boolean, loadedArg: number, totalArg: number): void; } -declare var ProgressEvent: { - prototype: ProgressEvent; - new (): ProgressEvent; -} interface IDBObjectStore { indexNames: DOMStringList; @@ -11688,10 +10434,6 @@ interface IDBObjectStore { get(key: any): IDBRequest; delete(key: any): IDBRequest; } -declare var IDBObjectStore: { - prototype: IDBObjectStore; - new (): IDBObjectStore; -} interface HTMLCanvasElement { /** @@ -11706,10 +10448,6 @@ interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandar stdDeviationY: SVGAnimatedNumber; setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; } -declare var SVGFEGaussianBlurElement: { - prototype: SVGFEGaussianBlurElement; - new (): SVGFEGaussianBlurElement; -} interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { y: SVGAnimatedLength; @@ -11722,52 +10460,31 @@ interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { interface Element { msRegionOverflow: string; onmspointerdown: (ev: any) => any; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; onmsgotpointercapture: (ev: any) => any; - addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; onmsgesturedoubletap: (ev: any) => any; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; onmspointerhover: (ev: any) => any; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; onmsgesturehold: (ev: any) => any; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; onmspointermove: (ev: any) => any; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; onmsgesturechange: (ev: any) => any; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; onmsgesturestart: (ev: any) => any; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; onmspointercancel: (ev: any) => any; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; onmsgestureend: (ev: any) => any; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; onmsgesturetap: (ev: any) => any; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; onmspointerout: (ev: any) => any; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; onmsinertiastart: (ev: any) => any; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; onmslostpointercapture: (ev: any) => any; - addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; onmspointerover: (ev: any) => any; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; msContentZoomFactor: number; onmspointerup: (ev: any) => any; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; msGetRegionContent(): MSRangeCollection; msReleasePointerCapture(pointerId: number): void; msSetPointerCapture(pointerId: number): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } interface IDBVersionChangeEvent extends Event { newVersion: number; oldVersion: number; } -declare var IDBVersionChangeEvent: { - prototype: IDBVersionChangeEvent; - new (): IDBVersionChangeEvent; -} interface IDBIndex { unique: boolean; @@ -11780,10 +10497,6 @@ interface IDBIndex { get(key: any): IDBRequest; openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; } -declare var IDBIndex: { - prototype: IDBIndex; - new (): IDBIndex; -} interface WheelEvent { getCurrentPoint(element: Element): void; @@ -11794,10 +10507,6 @@ interface FileList { item(index: number): File; [index: number]: File; } -declare var FileList: { - prototype: FileList; - new (): FileList; -} interface IDBCursor { source: any; @@ -11808,18 +10517,6 @@ interface IDBCursor { delete(): IDBRequest; continue(key?: any): void; update(value: any): IDBRequest; - PREV: string; - PREV_NO_DUPLICATE: string; - NEXT: string; - NEXT_NO_DUPLICATE: string; -} -declare var IDBCursor: { - prototype: IDBCursor; - new (): IDBCursor; - PREV: string; - PREV_NO_DUPLICATE: string; - NEXT: string; - NEXT_NO_DUPLICATE: string; } interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { @@ -11830,19 +10527,11 @@ interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveSta kernelUnitLengthX: SVGAnimatedNumber; specularConstant: SVGAnimatedNumber; } -declare var SVGFESpecularLightingElement: { - prototype: SVGFESpecularLightingElement; - new (): SVGFESpecularLightingElement; -} interface File extends Blob { lastModifiedDate: any; name: string; } -declare var File: { - prototype: File; - new (): File; -} interface URL { revokeObjectURL(url: string): void; @@ -11857,10 +10546,6 @@ interface RangeException { interface IDBCursorWithValue extends IDBCursor { value: any; } -declare var IDBCursorWithValue: { - prototype: IDBCursorWithValue; - new (): IDBCursorWithValue; -} interface HTMLTextAreaElement { /** @@ -11904,24 +10589,12 @@ interface HTMLTextAreaElement { interface XMLHttpRequestEventTarget extends EventTarget { onprogress: (ev: ProgressEvent) => any; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; onload: (ev: any) => any; - addEventListener(type: "load", listener: (ev: any) => any, useCapture?: boolean): void; ontimeout: (ev: any) => any; - addEventListener(type: "timeout", listener: (ev: any) => any, useCapture?: boolean): void; onabort: (ev: any) => any; - addEventListener(type: "abort", listener: (ev: any) => any, useCapture?: boolean): void; onloadstart: (ev: any) => any; - addEventListener(type: "loadstart", listener: (ev: any) => any, useCapture?: boolean): void; onloadend: (ev: ProgressEvent) => any; - addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var XMLHttpRequestEventTarget: { - prototype: XMLHttpRequestEventTarget; - new (): XMLHttpRequestEventTarget; } interface IDBEnvironment { @@ -11932,36 +10605,22 @@ interface IDBEnvironment { interface AudioTrackList extends EventTarget { length: number; onchange: (ev: any) => any; - addEventListener(type: "change", listener: (ev: any) => any, useCapture?: boolean): void; onaddtrack: (ev: TrackEvent) => any; - addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; getTrackById(id: string): AudioTrack; item(index: number): AudioTrack; [index: number]: AudioTrack; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var AudioTrackList: { - prototype: AudioTrackList; - new (): AudioTrackList; } interface MSBaseReader extends EventTarget { onprogress: (ev: ProgressEvent) => any; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; readyState: number; onabort: (ev: any) => any; - addEventListener(type: "abort", listener: (ev: any) => any, useCapture?: boolean): void; onloadend: (ev: ProgressEvent) => any; - addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; onload: (ev: any) => any; - addEventListener(type: "load", listener: (ev: any) => any, useCapture?: boolean): void; onloadstart: (ev: any) => any; - addEventListener(type: "loadstart", listener: (ev: any) => any, useCapture?: boolean): void; result: any; abort(): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; LOADING: number; EMPTY: number; DONE: number; @@ -11983,8 +10642,6 @@ interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardA SVG_MORPHOLOGY_OPERATOR_DILATE: number; } declare var SVGFEMorphologyElement: { - prototype: SVGFEMorphologyElement; - new (): SVGFEMorphologyElement; SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; SVG_MORPHOLOGY_OPERATOR_ERODE: number; SVG_MORPHOLOGY_OPERATOR_DILATE: number; @@ -12028,7 +10685,6 @@ interface CSSRule { VIEWPORT_RULE: number; } //declare var CSSRule: { -// prototype: CSSRule; // KEYFRAMES_RULE: number; // KEYFRAME_RULE: number; // VIEWPORT_RULE: number; @@ -12036,10 +10692,6 @@ interface CSSRule { interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { } -declare var SVGFEFuncRElement: { - prototype: SVGFEFuncRElement; - new (): SVGFEFuncRElement; -} interface WindowTimersExtension { msSetImmediate(expression: any, ...args: any[]): number; @@ -12061,8 +10713,6 @@ interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStan SVG_CHANNEL_A: number; } declare var SVGFEDisplacementMapElement: { - prototype: SVGFEDisplacementMapElement; - new (): SVGFEDisplacementMapElement; SVG_CHANNEL_B: number; SVG_CHANNEL_R: number; SVG_CHANNEL_G: number; @@ -12075,10 +10725,6 @@ interface AnimationEvent extends Event { elapsedTime: number; initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; } -declare var AnimationEvent: { - prototype: AnimationEvent; - new (): AnimationEvent; -} interface SVGComponentTransferFunctionElement extends SVGElement { tableValues: SVGAnimatedNumberList; @@ -12096,8 +10742,6 @@ interface SVGComponentTransferFunctionElement extends SVGElement { SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; } declare var SVGComponentTransferFunctionElement: { - prototype: SVGComponentTransferFunctionElement; - new (): SVGComponentTransferFunctionElement; SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; @@ -12111,19 +10755,11 @@ interface MSRangeCollection { item(index: number): Range; [index: number]: Range; } -declare var MSRangeCollection: { - prototype: MSRangeCollection; - new (): MSRangeCollection; -} interface SVGFEDistantLightElement extends SVGElement { azimuth: SVGAnimatedNumber; elevation: SVGAnimatedNumber; } -declare var SVGFEDistantLightElement: { - prototype: SVGFEDistantLightElement; - new (): SVGFEDistantLightElement; -} interface SVGException { name: string; @@ -12131,10 +10767,6 @@ interface SVGException { interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { } -declare var SVGFEFuncBElement: { - prototype: SVGFEFuncBElement; - new (): SVGFEFuncBElement; -} interface IDBKeyRange { upper: any; @@ -12146,10 +10778,6 @@ interface IDBKeyRange { lowerBound(bound: any, open?: boolean): IDBKeyRange; upperBound(bound: any, open?: boolean): IDBKeyRange; } -declare var IDBKeyRange: { - prototype: IDBKeyRange; - new (): IDBKeyRange; -} interface WindowConsole { console: Console; @@ -12157,27 +10785,13 @@ interface WindowConsole { interface IDBTransaction extends EventTarget { oncomplete: (ev: Event) => any; - addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; db: IDBDatabase; mode: string; error: DOMError; onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; onabort: (ev: any) => any; - addEventListener(type: "abort", listener: (ev: any) => any, useCapture?: boolean): void; abort(): void; objectStore(name: string): IDBObjectStore; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; - READ_ONLY: string; - VERSION_CHANGE: string; - READ_WRITE: string; -} -declare var IDBTransaction: { - prototype: IDBTransaction; - new (): IDBTransaction; - READ_ONLY: string; - VERSION_CHANGE: string; - READ_WRITE: string; } interface AudioTrack { @@ -12187,10 +10801,6 @@ interface AudioTrack { label: string; enabled: boolean; } -declare var AudioTrack: { - prototype: AudioTrack; - new (): AudioTrack; -} interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { orderY: SVGAnimatedInteger; @@ -12211,8 +10821,6 @@ interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStand SVG_EDGEMODE_NONE: number; } declare var SVGFEConvolveMatrixElement: { - prototype: SVGFEConvolveMatrixElement; - new (): SVGFEConvolveMatrixElement; SVG_EDGEMODE_WRAP: number; SVG_EDGEMODE_DUPLICATE: number; SVG_EDGEMODE_UNKNOWN: number; @@ -12225,10 +10833,6 @@ interface TextTrackCueList { [index: number]: TextTrackCue; getCueById(id: string): TextTrackCue; } -declare var TextTrackCueList: { - prototype: TextTrackCueList; - new (): TextTrackCueList; -} interface CSSKeyframesRule extends CSSRule { name: string; @@ -12237,45 +10841,26 @@ interface CSSKeyframesRule extends CSSRule { deleteRule(rule: string): void; appendRule(rule: string): void; } -declare var CSSKeyframesRule: { - prototype: CSSKeyframesRule; - new (): CSSKeyframesRule; -} interface Window extends WindowBase64, IDBEnvironment, WindowConsole { onmspointerdown: (ev: any) => any; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; animationStartTime: number; onmsgesturedoubletap: (ev: any) => any; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; onmspointerhover: (ev: any) => any; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; onmsgesturehold: (ev: any) => any; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; onmspointermove: (ev: any) => any; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; onmsgesturechange: (ev: any) => any; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; onmsgesturestart: (ev: any) => any; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; onmspointercancel: (ev: any) => any; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; onmsgestureend: (ev: any) => any; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; onmsgesturetap: (ev: any) => any; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; onmspointerout: (ev: any) => any; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; msAnimationStartTime: number; applicationCache: ApplicationCache; onmsinertiastart: (ev: any) => any; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; onmspointerover: (ev: any) => any; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; onpopstate: (ev: PopStateEvent) => any; - addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; onmspointerup: (ev: any) => any; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; msCancelRequestAnimationFrame(handle: number): void; matchMedia(mediaQuery: string): MediaQueryList; cancelAnimationFrame(handle: number): void; @@ -12300,8 +10885,6 @@ interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardA SVG_STITCHTYPE_STITCH: number; } declare var SVGFETurbulenceElement: { - prototype: SVGFETurbulenceElement; - new (): SVGFETurbulenceElement; SVG_STITCHTYPE_UNKNOWN: number; SVG_STITCHTYPE_NOSTITCH: number; SVG_TURBULENCE_TYPE_UNKNOWN: number; @@ -12315,17 +10898,9 @@ interface TextTrackList { item(index: number): TextTrack; [index: number]: TextTrack; } -declare var TextTrackList: { - prototype: TextTrackList; - new (): TextTrackList; -} interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { } -declare var SVGFEFuncGElement: { - prototype: SVGFEFuncGElement; - new (): SVGFEFuncGElement; -} interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { in1: SVGAnimatedString; @@ -12338,8 +10913,6 @@ interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandard SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; } declare var SVGFEColorMatrixElement: { - prototype: SVGFEColorMatrixElement; - new (): SVGFEColorMatrixElement; SVG_FECOLORMATRIX_TYPE_SATURATE: number; SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; SVG_FECOLORMATRIX_TYPE_MATRIX: number; @@ -12359,10 +10932,6 @@ interface Console { log(message?: any, ...optionalParams: any[]): void; profileEnd(): void; } -declare var Console: { - prototype: Console; - new (): Console; -} interface SVGFESpotLightElement extends SVGElement { pointsAtY: SVGAnimatedNumber; @@ -12374,10 +10943,6 @@ interface SVGFESpotLightElement extends SVGElement { z: SVGAnimatedNumber; pointsAtX: SVGAnimatedNumber; } -declare var SVGFESpotLightElement: { - prototype: SVGFESpotLightElement; - new (): SVGFESpotLightElement; -} interface HTMLImageElement { /** @@ -12404,18 +10969,11 @@ interface IDBDatabase extends EventTarget { name: string; objectStoreNames: DOMStringList; onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; onabort: (ev: any) => any; - addEventListener(type: "abort", listener: (ev: any) => any, useCapture?: boolean): void; createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; close(): void; transaction(storeNames: any, mode?: string): IDBTransaction; deleteObjectStore(name: string): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var IDBDatabase: { - prototype: IDBDatabase; - new (): IDBDatabase; } interface DOMStringList { @@ -12424,10 +10982,6 @@ interface DOMStringList { item(index: number): string; [index: number]: string; } -declare var DOMStringList: { - prototype: DOMStringList; - new (): DOMStringList; -} interface HTMLButtonElement { /** @@ -12479,14 +11033,7 @@ interface HTMLButtonElement { interface IDBOpenDBRequest extends IDBRequest { onupgradeneeded: (ev: IDBVersionChangeEvent) => any; - addEventListener(type: "upgradeneeded", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; onblocked: (ev: Event) => any; - addEventListener(type: "blocked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var IDBOpenDBRequest: { - prototype: IDBOpenDBRequest; - new (): IDBOpenDBRequest; } interface HTMLProgressElement extends HTMLElement { @@ -12507,10 +11054,6 @@ interface HTMLProgressElement extends HTMLElement { */ form: HTMLFormElement; } -declare var HTMLProgressElement: { - prototype: HTMLProgressElement; - new (): HTMLProgressElement; -} interface MSLaunchUriCallback { (): void; @@ -12521,10 +11064,6 @@ interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttri in1: SVGAnimatedString; dx: SVGAnimatedNumber; } -declare var SVGFEOffsetElement: { - prototype: SVGFEOffsetElement; - new (): SVGFEOffsetElement; -} interface HTMLFormElement { /** @@ -12547,42 +11086,26 @@ interface MSUnsafeFunctionCallback { interface Document { onmspointerdown: (ev: any) => any; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; msHidden: boolean; msVisibilityState: string; onmsgesturedoubletap: (ev: any) => any; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; visibilityState: string; onmsmanipulationstatechanged: (ev: any) => any; - addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; onmspointerhover: (ev: any) => any; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; onmscontentzoom: (ev: any) => any; - addEventListener(type: "mscontentzoom", listener: (ev: any) => any, useCapture?: boolean): void; onmspointermove: (ev: any) => any; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; onmsgesturehold: (ev: any) => any; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; onmsgesturechange: (ev: any) => any; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; onmsgesturestart: (ev: any) => any; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; onmspointercancel: (ev: any) => any; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; onmsgestureend: (ev: any) => any; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; onmsgesturetap: (ev: any) => any; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; onmspointerout: (ev: any) => any; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; onmsinertiastart: (ev: any) => any; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; msCSSOMElementFloatMetrics: boolean; onmspointerover: (ev: any) => any; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; hidden: boolean; onmspointerup: (ev: any) => any; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; msElementsFromPoint(x: number, y: number): NodeList; msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; clear(): void; @@ -12647,14 +11170,10 @@ interface TextTrack extends EventTarget { activeCues: TextTrackCueList; cues: TextTrackCueList; oncuechange: (ev: Event) => any; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; kind: string; onload: (ev: any) => any; - addEventListener(type: "load", listener: (ev: any) => any, useCapture?: boolean): void; onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; label: string; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; ERROR: number; SHOWING: number; LOADING: number; @@ -12664,8 +11183,6 @@ interface TextTrack extends EventTarget { DISABLED: number; } declare var TextTrack: { - prototype: TextTrack; - new (): TextTrack; ERROR: number; SHOWING: number; LOADING: number; @@ -12682,31 +11199,18 @@ interface MediaQueryListListener { interface IDBRequest extends EventTarget { source: any; onsuccess: (ev: Event) => any; - addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; error: DOMError; transaction: IDBTransaction; onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; readyState: string; result: any; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var IDBRequest: { - prototype: IDBRequest; - new (): IDBRequest; } interface MessagePort extends EventTarget { onmessage: (ev: any) => any; - addEventListener(type: "message", listener: (ev: any) => any, useCapture?: boolean): void; close(): void; - postMessage(message: any, ports?: any): void; + postMessage(message?: any, ports?: any): void; start(): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var MessagePort: { - prototype: MessagePort; - new (): MessagePort; } interface FileReader extends MSBaseReader { @@ -12730,7 +11234,6 @@ interface Blob { size: number; msDetachStream(): any; slice(start?: number, end?: number, contentType?: string): Blob; - close(): void; msClose(): void; } declare var Blob: { @@ -12741,25 +11244,16 @@ declare var Blob: { interface ApplicationCache extends EventTarget { status: number; ondownloading: (ev: Event) => any; - addEventListener(type: "downloading", listener: (ev: Event) => any, useCapture?: boolean): void; onprogress: (ev: ProgressEvent) => any; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; onupdateready: (ev: Event) => any; - addEventListener(type: "updateready", listener: (ev: Event) => any, useCapture?: boolean): void; oncached: (ev: Event) => any; - addEventListener(type: "cached", listener: (ev: Event) => any, useCapture?: boolean): void; onobsolete: (ev: Event) => any; - addEventListener(type: "obsolete", listener: (ev: Event) => any, useCapture?: boolean): void; onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; onchecking: (ev: Event) => any; - addEventListener(type: "checking", listener: (ev: Event) => any, useCapture?: boolean): void; onnoupdate: (ev: Event) => any; - addEventListener(type: "noupdate", listener: (ev: Event) => any, useCapture?: boolean): void; swapCache(): void; abort(): void; update(): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; CHECKING: number; UNCACHED: number; UPDATEREADY: number; @@ -12768,8 +11262,6 @@ interface ApplicationCache extends EventTarget { OBSOLETE: number; } declare var ApplicationCache: { - prototype: ApplicationCache; - new (): ApplicationCache; CHECKING: number; UNCACHED: number; UPDATEREADY: number; @@ -12786,36 +11278,23 @@ interface XMLHttpRequest { response: any; withCredentials: boolean; onprogress: (ev: ProgressEvent) => any; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; onabort: (ev: any) => any; - addEventListener(type: "abort", listener: (ev: any) => any, useCapture?: boolean): void; responseType: string; onloadend: (ev: ProgressEvent) => any; - addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; upload: XMLHttpRequestEventTarget; onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; onloadstart: (ev: any) => any; - addEventListener(type: "loadstart", listener: (ev: any) => any, useCapture?: boolean): void; } interface PopStateEvent extends Event { state: any; initPopStateEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, stateArg: any): void; } -declare var PopStateEvent: { - prototype: PopStateEvent; - new (): PopStateEvent; -} interface CSSKeyframeRule extends CSSRule { keyText: string; style: CSSStyleDeclaration; } -declare var CSSKeyframeRule: { - prototype: CSSKeyframeRule; - new (): CSSKeyframeRule; -} interface MSFileSaver { msSaveBlob(blob: any, defaultName?: string): boolean; @@ -12827,10 +11306,6 @@ interface MSStream { msDetachStream(): any; msClose(): void; } -declare var MSStream: { - prototype: MSStream; - new (): MSStream; -} interface MediaError { msExtendedCode: number; @@ -12871,13 +11346,10 @@ declare var MSBlobBuilder: { interface HTMLElement { onmscontentzoom: (ev: any) => any; - addEventListener(type: "mscontentzoom", listener: (ev: any) => any, useCapture?: boolean): void; oncuechange: (ev: Event) => any; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; spellcheck: boolean; classList: DOMTokenList; onmsmanipulationstatechanged: (ev: any) => any; - addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; draggable: boolean; } @@ -12889,20 +11361,12 @@ interface DataTransfer { interface DOMSettableTokenList extends DOMTokenList { value: string; } -declare var DOMSettableTokenList: { - prototype: DOMSettableTokenList; - new (): DOMSettableTokenList; -} interface IDBFactory { open(name: string, version?: number): IDBOpenDBRequest; cmp(first: any, second: any): number; deleteDatabase(name: string): IDBOpenDBRequest; } -declare var IDBFactory: { - prototype: IDBFactory; - new (): IDBFactory; -} interface Range { createContextualFragment(fragment: string): DocumentFragment; @@ -12953,8 +11417,6 @@ interface MSPointerEvent extends MouseEvent { MSPOINTER_TYPE_TOUCH: number; } declare var MSPointerEvent: { - prototype: MSPointerEvent; - new (): MSPointerEvent; MSPOINTER_TYPE_PEN: number; MSPOINTER_TYPE_MOUSE: number; MSPOINTER_TYPE_TOUCH: number; @@ -12967,7 +11429,6 @@ interface DOMException { TIMEOUT_ERR: number; } //declare var DOMException: { -// prototype: DOMException; // INVALID_NODE_TYPE_ERR: number; // DATA_CLONE_ERR: number; // TIMEOUT_ERR: number; @@ -12982,8 +11443,6 @@ interface MSManipulationEvent extends UIEvent { MS_MANIPULATION_STATE_INERTIA: number; } declare var MSManipulationEvent: { - prototype: MSManipulationEvent; - new (): MSManipulationEvent; MS_MANIPULATION_STATE_STOPPED: number; MS_MANIPULATION_STATE_ACTIVE: number; MS_MANIPULATION_STATE_INERTIA: number; @@ -13000,23 +11459,13 @@ declare var FormData: { interface HTMLDataListElement extends HTMLElement { options: HTMLCollection; } -declare var HTMLDataListElement: { - prototype: HTMLDataListElement; - new (): HTMLDataListElement; -} interface SVGFEImageElement extends SVGElement, SVGLangSpace, SVGFilterPrimitiveStandardAttributes, SVGURIReference, SVGExternalResourcesRequired { preserveAspectRatio: SVGAnimatedPreserveAspectRatio; } -declare var SVGFEImageElement: { - prototype: SVGFEImageElement; - new (): SVGFEImageElement; -} interface AbstractWorker extends EventTarget { onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { @@ -13036,8 +11485,6 @@ interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAt SVG_FECOMPOSITE_OPERATOR_ATOP: number; } declare var SVGFECompositeElement: { - prototype: SVGFECompositeElement; - new (): SVGFECompositeElement; SVG_FECOMPOSITE_OPERATOR_OUT: number; SVG_FECOMPOSITE_OPERATOR_OVER: number; SVG_FECOMPOSITE_OPERATOR_XOR: number; @@ -13058,10 +11505,6 @@ interface ValidityState { tooLong: boolean; valid: boolean; } -declare var ValidityState: { - prototype: ValidityState; - new (): ValidityState; -} interface HTMLTrackElement extends HTMLElement { kind: string; @@ -13071,10 +11514,6 @@ interface HTMLTrackElement extends HTMLElement { label: string; default: boolean; } -declare var HTMLTrackElement: { - prototype: HTMLTrackElement; - new (): HTMLTrackElement; -} interface MSApp { createFileFromStorageFile(storageFile: any): File; @@ -13093,28 +11532,20 @@ interface HTMLVideoElement { msIsStereo3D: boolean; msStereo3DPackingMode: string; onMSVideoOptimalLayoutChanged: (ev: any) => any; - addEventListener(type: "MSVideoOptimalLayoutChanged", listener: (ev: any) => any, useCapture?: boolean): void; onMSVideoFrameStepCompleted: (ev: any) => any; - addEventListener(type: "MSVideoFrameStepCompleted", listener: (ev: any) => any, useCapture?: boolean): void; msStereo3DRenderMode: string; msIsLayoutOptimalForPlayback: boolean; msHorizontalMirror: boolean; onMSVideoFormatChanged: (ev: any) => any; - addEventListener(type: "MSVideoFormatChanged", listener: (ev: any) => any, useCapture?: boolean): void; msZoom: boolean; msInsertVideoEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; msSetVideoRectangle(left: number, top: number, right: number, bottom: number): void; msFrameStep(forward: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { in1: SVGAnimatedString; } -declare var SVGFEComponentTransferElement: { - prototype: SVGFEComponentTransferElement; - new (): SVGFEComponentTransferElement; -} interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { kernelUnitLengthY: SVGAnimatedNumber; @@ -13123,10 +11554,6 @@ interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStan kernelUnitLengthX: SVGAnimatedNumber; diffuseConstant: SVGAnimatedNumber; } -declare var SVGFEDiffuseLightingElement: { - prototype: SVGFEDiffuseLightingElement; - new (): SVGFEDiffuseLightingElement; -} interface MSCSSMatrix { m24: number; @@ -13169,10 +11596,8 @@ declare var MSCSSMatrix: { interface Worker extends AbstractWorker { onmessage: (ev: any) => any; - addEventListener(type: "message", listener: (ev: any) => any, useCapture?: boolean): void; postMessage(message: any, ports?: any): void; terminate(): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } declare var Worker: { prototype: Worker; @@ -13184,38 +11609,23 @@ interface HTMLIFrameElement { } declare var onmspointerdown: (ev: any) => any; -declare function addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; declare var animationStartTime: number; declare var onmsgesturedoubletap: (ev: any) => any; -declare function addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; declare var onmspointerhover: (ev: any) => any; -declare function addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; declare var onmsgesturehold: (ev: any) => any; -declare function addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; declare var onmspointermove: (ev: any) => any; -declare function addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; declare var onmsgesturechange: (ev: any) => any; -declare function addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; declare var onmsgesturestart: (ev: any) => any; -declare function addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; declare var onmspointercancel: (ev: any) => any; -declare function addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; declare var onmsgestureend: (ev: any) => any; -declare function addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; declare var onmsgesturetap: (ev: any) => any; -declare function addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; declare var onmspointerout: (ev: any) => any; -declare function addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; declare var msAnimationStartTime: number; declare var applicationCache: ApplicationCache; declare var onmsinertiastart: (ev: any) => any; -declare function addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; declare var onmspointerover: (ev: any) => any; -declare function addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; declare var onpopstate: (ev: PopStateEvent) => any; -declare function addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; declare var onmspointerup: (ev: any) => any; -declare function addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; declare function msCancelRequestAnimationFrame(handle: number): void; declare function matchMedia(mediaQuery: string): MediaQueryList; declare function cancelAnimationFrame(handle: number): void; @@ -13229,10 +11639,10 @@ declare var msIndexedDB: IDBFactory; declare var indexedDB: IDBFactory; declare var console: Console; -///////////////////////////// -/// IE11 APIs -///////////////////////////// +///////////////////////////// +/// IE11 DOM APIs +///////////////////////////// interface StoreExceptionsInformation extends ExceptionInformation { @@ -13296,16 +11706,10 @@ interface NavigatorID { product: string; vendor: string; } -declare var NavigatorID: { - prototype: NavigatorID; - new (): NavigatorID; -} interface HTMLBodyElement { onpageshow: (ev: PageTransitionEvent) => any; - addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; onpagehide: (ev: PageTransitionEvent) => any; - addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; } interface MSExecAtPriorityFunctionCallback { @@ -13316,26 +11720,18 @@ interface MSWindowExtensions { captureEvents(): void; releaseEvents(): void; } -declare var MSWindowExtensions: { - prototype: MSWindowExtensions; - new (): MSWindowExtensions; -} interface MSGraphicsTrust { status: string; constrictionActive: boolean; } -declare var MSGraphicsTrust: { - prototype: MSGraphicsTrust; - new (): MSGraphicsTrust; -} interface AudioTrack { sourceBuffer: SourceBuffer; } interface DragEvent { - msConvertURL(file: File, targetType: string, targetURL?: string): boolean; + msConvertURL(file: File, targetType: string, targetURL?: string): void; } interface SubtleCrypto { @@ -13351,44 +11747,39 @@ interface SubtleCrypto { sign(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; decrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; } -declare var SubtleCrypto: { - prototype: SubtleCrypto; - new (): SubtleCrypto; -} interface Crypto extends RandomSource { subtle: SubtleCrypto; } -declare var Crypto: { - prototype: Crypto; - new (): Crypto; -} interface VideoPlaybackQuality { + totalFrameDelay: number; creationTime: number; totalVideoFrames: number; droppedVideoFrames: number; } -declare var VideoPlaybackQuality: { - prototype: VideoPlaybackQuality; - new (): VideoPlaybackQuality; + +interface GlobalEventHandlers { + onpointerenter: (ev: PointerEvent) => any; + onpointerout: (ev: PointerEvent) => any; + onpointerdown: (ev: PointerEvent) => any; + onpointerup: (ev: PointerEvent) => any; + onpointercancel: (ev: PointerEvent) => any; + onpointerover: (ev: PointerEvent) => any; + onpointermove: (ev: PointerEvent) => any; + onpointerleave: (ev: PointerEvent) => any; } -interface Window { +interface Window extends GlobalEventHandlers { onpageshow: (ev: PageTransitionEvent) => any; - addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; ondevicemotion: (ev: DeviceMotionEvent) => any; - addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; devicePixelRatio: number; msCrypto: Crypto; ondeviceorientation: (ev: DeviceOrientationEvent) => any; - addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; + doNotTrack: string; onmspointerenter: (ev: any) => any; - addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; onpagehide: (ev: PageTransitionEvent) => any; - addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; onmspointerleave: (ev: any) => any; - addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; } interface Key { @@ -13397,15 +11788,9 @@ interface Key { extractable: boolean; keyUsage: string[]; } -declare var Key: { - prototype: Key; - new (): Key; -} interface TextTrackList extends EventTarget { onaddtrack: (ev: any) => any; - addEventListener(type: "addtrack", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } interface DeviceAcceleration { @@ -13413,10 +11798,6 @@ interface DeviceAcceleration { x: number; z: number; } -declare var DeviceAcceleration: { - prototype: DeviceAcceleration; - new (): DeviceAcceleration; -} interface Console { count(countTitle?: string): void; @@ -13432,45 +11813,35 @@ interface Console { } interface MSNavigatorDoNotTrack { - removeSiteSpecificTrackingException(args: ExceptionInformation): boolean; - removeWebWideTrackingException(args: ExceptionInformation): boolean; + removeSiteSpecificTrackingException(args: ExceptionInformation): void; + removeWebWideTrackingException(args: ExceptionInformation): void; storeWebWideTrackingException(args: StoreExceptionsInformation): void; storeSiteSpecificTrackingException(args: StoreSiteSpecificExceptionsInformation): void; confirmSiteSpecificTrackingException(args: ConfirmSiteSpecificExceptionsInformation): boolean; confirmWebWideTrackingException(args: ExceptionInformation): boolean; } -declare var MSNavigatorDoNotTrack: { - prototype: MSNavigatorDoNotTrack; - new (): MSNavigatorDoNotTrack; -} interface HTMLImageElement { crossOrigin: string; + msPlayToPreferredSourceUri: string; } interface HTMLAllCollection extends HTMLCollection { namedItem(name: string): Element; -} -declare var HTMLAllCollection: { - prototype: HTMLAllCollection; - new (): HTMLAllCollection; + //[name: string]: Element; } interface MSNavigatorExtensions { language: string; } -declare var MSNavigatorExtensions: { - prototype: MSNavigatorExtensions; - new (): MSNavigatorExtensions; -} interface AesGcmEncryptResult { ciphertext: ArrayBuffer; tag: ArrayBuffer; } -declare var AesGcmEncryptResult: { - prototype: AesGcmEncryptResult; - new (): AesGcmEncryptResult; + +interface HTMLSourceElement { + msKeySystem: string; } interface CSSStyleDeclaration { @@ -13489,6 +11860,7 @@ interface CSSStyleDeclaration { flexWrap: string; borderImageOutset: string; flexDirection: string; + touchAction: string; flexFlow: string; borderImage: string; justifyContent: string; @@ -13496,18 +11868,10 @@ interface CSSStyleDeclaration { msTextCombineHorizontal: string; } -interface HTMLSourceElement { - msKeySystem: string; -} - interface NavigationCompletedEvent extends NavigationEvent { webErrorStatus: number; isSuccess: boolean; } -declare var NavigationCompletedEvent: { - prototype: NavigationCompletedEvent; - new (): NavigationCompletedEvent; -} interface MutationRecord { oldValue: string; @@ -13520,22 +11884,19 @@ interface MutationRecord { attributeNamespace: string; type: string; } -declare var MutationRecord: { - prototype: MutationRecord; - new (): MutationRecord; + +interface Navigator { + pointerEnabled: boolean; + maxTouchPoints: number; } -interface Document extends MSDocumentExtensions { +interface Document extends MSDocumentExtensions, GlobalEventHandlers { msFullscreenEnabled: boolean; onmsfullscreenerror: (ev: any) => any; - addEventListener(type: "msfullscreenerror", listener: (ev: any) => any, useCapture?: boolean): void; onmspointerenter: (ev: any) => any; - addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; msFullscreenElement: Element; onmsfullscreenchange: (ev: any) => any; - addEventListener(type: "msfullscreenchange", listener: (ev: any) => any, useCapture?: boolean): void; onmspointerleave: (ev: any) => any; - addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; msExitFullscreen(): void; } @@ -13544,10 +11905,7 @@ interface MimeTypeArray { item(index: number): Plugin; [index: number]: Plugin; namedItem(type: string): Plugin; -} -declare var MimeTypeArray: { - prototype: MimeTypeArray; - new (): MimeTypeArray; + //[type: string]: Plugin; } interface HTMLMediaElement { @@ -13556,7 +11914,6 @@ interface HTMLMediaElement { */ msPlayToPreferredSourceUri: string; onmsneedkey: (ev: MSMediaKeyNeededEvent) => any; - addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; /** * Gets the MSMediaKeys object, which is used for decrypting media data, that is associated with this media element. */ @@ -13564,7 +11921,6 @@ interface HTMLMediaElement { msGraphicsTrustStatus: MSGraphicsTrust; msSetMediaKeys(mediaKeys: MSMediaKeys): void; addTextTrack(kind: string, label?: string, language?: string): TextTrack; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } interface TextTrack { @@ -13574,23 +11930,12 @@ interface TextTrack { interface KeyOperation extends EventTarget { oncomplete: (ev: any) => any; - addEventListener(type: "complete", listener: (ev: any) => any, useCapture?: boolean): void; onerror: (ev: any) => any; - addEventListener(type: "error", listener: (ev: any) => any, useCapture?: boolean): void; result: any; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var KeyOperation: { - prototype: KeyOperation; - new (): KeyOperation; } interface DOMStringMap { } -declare var DOMStringMap: { - prototype: DOMStringMap; - new (): DOMStringMap; -} interface DeviceOrientationEvent extends Event { gamma: number; @@ -13599,19 +11944,6 @@ interface DeviceOrientationEvent extends Event { beta: number; initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number, beta: number, gamma: number, absolute: boolean): void; } -declare var DeviceOrientationEvent: { - prototype: DeviceOrientationEvent; - new (): DeviceOrientationEvent; -} - -interface MSMediaKeyMessageEvent extends Event { - destinationURL: string; - message: Uint8Array; -} -declare var MSMediaKeyMessageEvent: { - prototype: MSMediaKeyMessageEvent; - new (): MSMediaKeyMessageEvent; -} interface MSMediaKeys { keySystem: string; @@ -13623,6 +11955,11 @@ declare var MSMediaKeys: { new (): MSMediaKeys; } +interface MSMediaKeyMessageEvent extends Event { + destinationURL: string; + message: Uint8Array; +} + interface MSHTMLWebViewElement extends HTMLElement { documentTitle: string; width: number; @@ -13643,26 +11980,20 @@ interface MSHTMLWebViewElement extends HTMLElement { invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; buildLocalStreamUri(contentIdentifier: string, relativePath: string): string; } -declare var MSHTMLWebViewElement: { - prototype: MSHTMLWebViewElement; - new (): MSHTMLWebViewElement; -} interface NavigationEvent extends Event { uri: string; } -declare var NavigationEvent: { - prototype: NavigationEvent; - new (): NavigationEvent; -} -interface Element { +interface Element extends GlobalEventHandlers { + onlostpointercapture: (ev: PointerEvent) => any; onmspointerenter: (ev: any) => any; - addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + ongotpointercapture: (ev: PointerEvent) => any; onmspointerleave: (ev: any) => any; - addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; msZoomTo(args: MsZoomToOptions): void; + setPointerCapture(pointerId: number): void; msGetUntransformedBounds(): ClientRect; + releasePointerCapture(pointerId: number): void; msRequestFullscreen(): void; } @@ -13688,30 +12019,18 @@ interface SourceBuffer extends EventTarget { abort(): void; appendStream(stream: MSStream, maxSize?: number): void; } -declare var SourceBuffer: { - prototype: SourceBuffer; - new (): SourceBuffer; -} interface MSInputMethodContext extends EventTarget { oncandidatewindowshow: (ev: any) => any; - addEventListener(type: "candidatewindowshow", listener: (ev: any) => any, useCapture?: boolean): void; target: HTMLElement; compositionStartOffset: number; oncandidatewindowhide: (ev: any) => any; - addEventListener(type: "candidatewindowhide", listener: (ev: any) => any, useCapture?: boolean): void; oncandidatewindowupdate: (ev: any) => any; - addEventListener(type: "candidatewindowupdate", listener: (ev: any) => any, useCapture?: boolean): void; compositionEndOffset: number; getCompositionAlternatives(): string[]; getCandidateWindowClientRect(): ClientRect; hasComposition(): boolean; isCandidateWindowVisible(): boolean; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var MSInputMethodContext: { - prototype: MSInputMethodContext; - new (): MSInputMethodContext; } interface DeviceRotationRate { @@ -13719,10 +12038,6 @@ interface DeviceRotationRate { alpha: number; beta: number; } -declare var DeviceRotationRate: { - prototype: DeviceRotationRate; - new (): DeviceRotationRate; -} interface PluginArray { length: number; @@ -13730,10 +12045,7 @@ interface PluginArray { item(index: number): Plugin; [index: number]: Plugin; namedItem(name: string): Plugin; -} -declare var PluginArray: { - prototype: PluginArray; - new (): PluginArray; + //[name: string]: Plugin; } interface MSMediaKeyError { @@ -13747,8 +12059,6 @@ interface MSMediaKeyError { MS_MEDIA_KEYERR_CLIENT: number; } declare var MSMediaKeyError: { - prototype: MSMediaKeyError; - new (): MSMediaKeyError; MS_MEDIA_KEYERR_SERVICE: number; MS_MEDIA_KEYERR_HARDWARECHANGE: number; MS_MEDIA_KEYERR_OUTPUT: number; @@ -13766,32 +12076,25 @@ interface Plugin { item(index: number): MimeType; [index: number]: MimeType; namedItem(type: string): MimeType; -} -declare var Plugin: { - prototype: Plugin; - new (): Plugin; + //[type: string]: MimeType; } interface HTMLFrameSetElement { onpageshow: (ev: PageTransitionEvent) => any; - addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; onpagehide: (ev: PageTransitionEvent) => any; - addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; } interface Screen extends EventTarget { msOrientation: string; onmsorientationchange: (ev: any) => any; - addEventListener(type: "msorientationchange", listener: (ev: any) => any, useCapture?: boolean): void; msLockOrientation(orientations: string[]): boolean; msUnlockOrientation(): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; } interface MediaSource extends EventTarget { sourceBuffers: SourceBufferList; - duration: string; - readyState: any; + duration: number; + readyState: string; activeSourceBuffers: SourceBufferList; addSourceBuffer(type: string): SourceBuffer; endOfStream(error?: string): void; @@ -13807,7 +12110,6 @@ interface MediaError { MS_MEDIA_ERR_ENCRYPTED: number; } //declare var MediaError: { -// prototype: MediaError; // MS_MEDIA_ERR_ENCRYPTED: number; //} @@ -13816,17 +12118,9 @@ interface SourceBufferList extends EventTarget { item(index: number): SourceBuffer; [index: number]: SourceBuffer; } -declare var SourceBufferList: { - prototype: SourceBufferList; - new (): SourceBufferList; -} interface XMLDocument extends Document { } -declare var XMLDocument: { - prototype: XMLDocument; - new (): XMLDocument; -} interface DeviceMotionEvent extends Event { rotationRate: DeviceRotationRate; @@ -13835,10 +12129,6 @@ interface DeviceMotionEvent extends Event { accelerationIncludingGravity: DeviceAcceleration; initDeviceMotionEvent(type: string, bubbles: boolean, cancelable: boolean, acceleration: DeviceAccelerationDict, accelerationIncludingGravity: DeviceAccelerationDict, rotationRate: DeviceRotationRateDict, interval: number): void; } -declare var DeviceMotionEvent: { - prototype: DeviceMotionEvent; - new (): DeviceMotionEvent; -} interface MimeType { enabledPlugin: Plugin; @@ -13846,9 +12136,23 @@ interface MimeType { type: string; description: string; } -declare var MimeType: { - prototype: MimeType; - new (): MimeType; + +interface PointerEvent extends MouseEvent { + width: number; + rotation: number; + pressure: number; + pointerType: any; + isPrimary: boolean; + tiltY: number; + height: number; + intermediatePoints: any; + currentPoint: any; + tiltX: number; + hwTimestamp: number; + pointerId: number; + initPointerEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, offsetXArg: number, offsetYArg: number, widthArg: number, heightArg: number, pressure: number, rotation: number, tiltX: number, tiltY: number, pointerIdArg: number, pointerType: any, hwTimestampArg: number, isPrimary: boolean): void; + getCurrentPoint(element: Element): void; + getIntermediatePoints(element: Element): void; } interface MSDocumentExtensions { @@ -13869,12 +12173,11 @@ interface MutationObserver { } declare var MutationObserver: { prototype: MutationObserver; - new (callback: (arr: MutationRecord[], observer: MutationObserver)=>any): MutationObserver; + new (): MutationObserver; } interface AudioTrackList { onremovetrack: (ev: PluginArray) => any; - //addEventListener(type: "removetrack", listener: (ev: PluginArray) => any, useCapture?: boolean): void; } interface HTMLObjectElement { @@ -13890,6 +12193,7 @@ interface HTMLObjectElement { * Gets or sets whether the DLNA PlayTo device is available. */ msPlayToDisabled: boolean; + readyState: number; /** * Gets the source associated with the media element for use by the PlayToManager. */ @@ -13909,6 +12213,7 @@ interface HTMLEmbedElement { * Gets or sets whether the DLNA PlayTo device is available. */ msPlayToDisabled: boolean; + readyState: string; /** * Gets the source associated with the media element for use by the PlayToManager. */ @@ -13918,15 +12223,12 @@ interface HTMLEmbedElement { interface MSWebViewAsyncOperation extends EventTarget { target: MSHTMLWebViewElement; oncomplete: (ev: any) => any; - addEventListener(type: "complete", listener: (ev: any) => any, useCapture?: boolean): void; error: DOMError; onerror: (ev: any) => any; - addEventListener(type: "error", listener: (ev: any) => any, useCapture?: boolean): void; readyState: number; type: number; result: any; start(): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; ERROR: number; TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; TYPE_INVOKE_SCRIPT: number; @@ -13935,8 +12237,6 @@ interface MSWebViewAsyncOperation extends EventTarget { STARTED: number; } declare var MSWebViewAsyncOperation: { - prototype: MSWebViewAsyncOperation; - new (): MSWebViewAsyncOperation; ERROR: number; TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; TYPE_INVOKE_SCRIPT: number; @@ -13949,10 +12249,6 @@ interface ScriptNotifyEvent extends Event { value: string; callingUri: string; } -declare var ScriptNotifyEvent: { - prototype: ScriptNotifyEvent; - new (): ScriptNotifyEvent; -} interface PerformanceNavigationTiming extends PerformanceEntry { redirectStart: number; @@ -13978,18 +12274,10 @@ interface PerformanceNavigationTiming extends PerformanceEntry { domContentLoadedEventEnd: number; type: string; } -declare var PerformanceNavigationTiming: { - prototype: PerformanceNavigationTiming; - new (): PerformanceNavigationTiming; -} interface MSMediaKeyNeededEvent extends Event { initData: Uint8Array; } -declare var MSMediaKeyNeededEvent: { - prototype: MSMediaKeyNeededEvent; - new (): MSMediaKeyNeededEvent; -} interface MSManipulationEvent { MS_MANIPULATION_STATE_SELECTING: number; @@ -13999,7 +12287,6 @@ interface MSManipulationEvent { MS_MANIPULATION_STATE_CANCELLED: number; } //declare var MSManipulationEvent: { -// prototype: MSManipulationEvent; // MS_MANIPULATION_STATE_SELECTING: number; // MS_MANIPULATION_STATE_COMMITTED: number; // MS_MANIPULATION_STATE_PRESELECT: number; @@ -14011,50 +12298,41 @@ interface LongRunningScriptDetectedEvent extends Event { stopPageScriptExecution: boolean; executionTime: number; } -declare var LongRunningScriptDetectedEvent: { - prototype: LongRunningScriptDetectedEvent; - new (): LongRunningScriptDetectedEvent; -} interface MSAppView { viewId: number; close(): void; postMessage(message: any, targetOrigin: string, ports?: any): void; } -declare var MSAppView: { - prototype: MSAppView; - new (): MSAppView; -} interface PerfWidgetExternal { maxCpuSpeed: number; - performanceCounterFrequency: number; + independentRenderingEnabled: boolean; + irDisablingContentString: string; + irStatusAvailable: boolean; performanceCounter: number; averagePaintTime: number; activeNetworkRequestCount: number; paintRequestsPerSecond: number; + extraInformationEnabled: boolean; + performanceCounterFrequency: number; + averageFrameTime: number; repositionWindow(x: number, y: number): void; getRecentMemoryUsage(last: number): any; getMemoryUsage(): number; resizeWindow(width: number, height: number): void; getProcessCpuUsage(): number; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; removeEventListener(eventType: string, callback: (ev: any) => any): void; getRecentCpuUsage(last: number): any; addEventListener(eventType: string, callback: (ev: any) => any): void; + getRecentFrames(last: number): any; getRecentPaintRequests(last: number): any; } -declare var PerfWidgetExternal: { - prototype: PerfWidgetExternal; - new (): PerfWidgetExternal; -} interface PageTransitionEvent extends Event { persisted: boolean; } -declare var PageTransitionEvent: { - prototype: PageTransitionEvent; - new (): PageTransitionEvent; -} interface MutationCallback { (mutations: MutationRecord[], observer: MutationObserver): void; @@ -14062,19 +12340,11 @@ interface MutationCallback { interface HTMLDocument extends Document { } -declare var HTMLDocument: { - prototype: HTMLDocument; - new (): HTMLDocument; -} interface KeyPair { privateKey: Key; publicKey: Key; } -declare var KeyPair: { - prototype: KeyPair; - new (): KeyPair; -} interface MSApp { getViewOpener(): MSAppView; @@ -14090,28 +12360,12 @@ interface MSApp { CURRENT: string; } //declare var MSApp: { -// prototype: MSApp; // NORMAL: string; // HIGH: string; // IDLE: string; // CURRENT: string; //} -interface HTMLTrackElement { - readyState: number; - ERROR: number; - LOADING: number; - LOADED: number; - NONE: number; -} -//declare var HTMLTrackElement: { -// prototype: HTMLTrackElement; -// ERROR: number; -// LOADING: number; -// LOADED: number; -// NONE: number; -//} - interface MSMediaKeySession extends EventTarget { sessionId: string; error: MSMediaKeyError; @@ -14119,59 +12373,2534 @@ interface MSMediaKeySession extends EventTarget { close(): void; update(key: Uint8Array): void; } -declare var MSMediaKeySession: { - prototype: MSMediaKeySession; - new (): MSMediaKeySession; + +interface HTMLTrackElement { + readyState: number; + ERROR: number; + LOADING: number; + LOADED: number; + NONE: number; } +//declare var HTMLTrackElement: { +// ERROR: number; +// LOADING: number; +// LOADED: number; +// NONE: number; +//} interface HTMLVideoElement { - videoPlaybackQuality: VideoPlaybackQuality; + getVideoPlaybackQuality(): VideoPlaybackQuality; } interface UnviewableContentIdentifiedEvent extends NavigationEvent { referrer: string; } -declare var UnviewableContentIdentifiedEvent: { - prototype: UnviewableContentIdentifiedEvent; - new (): UnviewableContentIdentifiedEvent; -} interface CryptoOperation extends EventTarget { algorithm: Algorithm; oncomplete: (ev: any) => any; - addEventListener(type: "complete", listener: (ev: any) => any, useCapture?: boolean): void; onerror: (ev: any) => any; - addEventListener(type: "error", listener: (ev: any) => any, useCapture?: boolean): void; onprogress: (ev: any) => any; - addEventListener(type: "progress", listener: (ev: any) => any, useCapture?: boolean): void; onabort: (ev: any) => any; - addEventListener(type: "abort", listener: (ev: any) => any, useCapture?: boolean): void; key: Key; result: any; abort(): void; finish(): void; process(buffer: ArrayBufferView): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var CryptoOperation: { - prototype: CryptoOperation; - new (): CryptoOperation; } declare var onpageshow: (ev: PageTransitionEvent) => any; -declare function addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; declare var ondevicemotion: (ev: DeviceMotionEvent) => any; -declare function addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; declare var devicePixelRatio: number; declare var msCrypto: Crypto; declare var ondeviceorientation: (ev: DeviceOrientationEvent) => any; -declare function addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; +declare var doNotTrack: string; declare var onmspointerenter: (ev: any) => any; -declare function addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; declare var onpagehide: (ev: PageTransitionEvent) => any; -declare function addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; declare var onmspointerleave: (ev: any) => any; +declare var onpointerenter: (ev: PointerEvent) => any; +declare var onpointerout: (ev: PointerEvent) => any; +declare var onpointerdown: (ev: PointerEvent) => any; +declare var onpointerup: (ev: PointerEvent) => any; +declare var onpointercancel: (ev: PointerEvent) => any; +declare var onpointerover: (ev: PointerEvent) => any; +declare var onpointermove: (ev: PointerEvent) => any; +declare var onpointerleave: (ev: PointerEvent) => any; + + +///////////////////////////// +/// WebGL APIs +///////////////////////////// + + +interface WebGLTexture extends WebGLObject { +} + +interface OES_texture_float { +} + +interface WebGLContextEvent extends Event { + statusMessage: string; +} +declare var WebGLContextEvent: { + prototype: WebGLContextEvent; + new (): WebGLContextEvent; +} + +interface WebGLRenderbuffer extends WebGLObject { +} + +interface WebGLUniformLocation { +} + +interface WebGLActiveInfo { + name: string; + type: number; + size: number; +} + +interface WEBGL_compressed_texture_s3tc { + COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + COMPRESSED_RGB_S3TC_DXT1_EXT: number; +} +declare var WEBGL_compressed_texture_s3tc: { + COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + COMPRESSED_RGB_S3TC_DXT1_EXT: number; +} + +interface WebGLContextAttributes { + alpha: boolean; + depth: boolean; + stencil: boolean; + antialias: boolean; + premultipliedAlpha: boolean; + preserveDrawingBuffer: boolean; +} + +interface WebGLRenderingContext { + drawingBufferWidth: number; + drawingBufferHeight: number; + canvas: HTMLCanvasElement; + getUniformLocation(program: WebGLProgram, name: string): WebGLUniformLocation; + bindTexture(target: number, texture: WebGLTexture): void; + bufferData(target: number, size: number, usage: number): void; + depthMask(flag: boolean): void; + getUniform(program: WebGLProgram, location: WebGLUniformLocation): any; + vertexAttrib3fv(indx: number, values: Float32Array): void; + linkProgram(program: WebGLProgram): void; + getSupportedExtensions(): string[]; + bufferSubData(target: number, offset: number, data: ArrayBufferView): void; + vertexAttribPointer(indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; + polygonOffset(factor: number, units: number): void; + blendColor(red: number, green: number, blue: number, alpha: number): void; + createTexture(): WebGLTexture; + hint(target: number, mode: number): void; + getVertexAttrib(index: number, pname: number): any; + enableVertexAttribArray(index: number): void; + depthRange(zNear: number, zFar: number): void; + cullFace(mode: number): void; + createFramebuffer(): WebGLFramebuffer; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + framebufferTexture2D(target: number, attachment: number, textarget: number, texture: WebGLTexture, level: number): void; + deleteFramebuffer(framebuffer: WebGLFramebuffer): void; + colorMask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void; + compressedTexImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, data: ArrayBufferView): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + getExtension(name: string): Object; + createProgram(): WebGLProgram; + deleteShader(shader: WebGLShader): void; + getAttachedShaders(program: WebGLProgram): WebGLShader[]; + enable(cap: number): void; + blendEquation(mode: number): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageData): void; + createBuffer(): WebGLBuffer; + deleteTexture(texture: WebGLTexture): void; + useProgram(program: WebGLProgram): void; + vertexAttrib2fv(indx: number, values: Float32Array): void; + checkFramebufferStatus(target: number): number; + frontFace(mode: number): void; + getBufferParameter(target: number, pname: number): any; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; + copyTexImage2D(target: number, level: number, internalformat: number, x: number, y: number, width: number, height: number, border: number): void; + getVertexAttribOffset(index: number, pname: number): number; + disableVertexAttribArray(index: number): void; + blendFunc(sfactor: number, dfactor: number): void; + drawElements(mode: number, count: number, type: number, offset: number): void; + isFramebuffer(framebuffer: WebGLFramebuffer): boolean; + uniform3iv(location: WebGLUniformLocation, v: Int32Array): void; + lineWidth(width: number): void; + getShaderInfoLog(shader: WebGLShader): string; + getTexParameter(target: number, pname: number): any; + getParameter(pname: number): any; + getShaderPrecisionFormat(shadertype: number, precisiontype: number): WebGLShaderPrecisionFormat; + getContextAttributes(): WebGLContextAttributes; + vertexAttrib1f(indx: number, x: number): void; + bindFramebuffer(target: number, framebuffer: WebGLFramebuffer): void; + compressedTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, data: ArrayBufferView): void; + isContextLost(): boolean; + uniform1iv(location: WebGLUniformLocation, v: Int32Array): void; + getRenderbufferParameter(target: number, pname: number): any; + uniform2fv(location: WebGLUniformLocation, v: Float32Array): void; + isTexture(texture: WebGLTexture): boolean; + getError(): number; + shaderSource(shader: WebGLShader, source: string): void; + deleteRenderbuffer(renderbuffer: WebGLRenderbuffer): void; + stencilMask(mask: number): void; + bindBuffer(target: number, buffer: WebGLBuffer): void; + getAttribLocation(program: WebGLProgram, name: string): number; + uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; + blendEquationSeparate(modeRGB: number, modeAlpha: number): void; + clear(mask: number): void; + blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void; + stencilFuncSeparate(face: number, func: number, ref: number, mask: number): void; + readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; + scissor(x: number, y: number, width: number, height: number): void; + uniform2i(location: WebGLUniformLocation, x: number, y: number): void; + getActiveAttrib(program: WebGLProgram, index: number): WebGLActiveInfo; + getShaderSource(shader: WebGLShader): string; + generateMipmap(target: number): void; + bindAttribLocation(program: WebGLProgram, index: number, name: string): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform2iv(location: WebGLUniformLocation, v: Int32Array): void; + stencilOp(fail: number, zfail: number, zpass: number): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array): void; + vertexAttrib1fv(indx: number, values: Float32Array): void; + flush(): void; + uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; + deleteProgram(program: WebGLProgram): void; + isRenderbuffer(renderbuffer: WebGLRenderbuffer): boolean; + uniform1i(location: WebGLUniformLocation, x: number): void; + getProgramParameter(program: WebGLProgram, pname: number): any; + getActiveUniform(program: WebGLProgram, index: number): WebGLActiveInfo; + stencilFunc(func: number, ref: number, mask: number): void; + pixelStorei(pname: number, param: number): void; + disable(cap: number): void; + vertexAttrib4fv(indx: number, values: Float32Array): void; + createRenderbuffer(): WebGLRenderbuffer; + isBuffer(buffer: WebGLBuffer): boolean; + stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void; + getFramebufferAttachmentParameter(target: number, attachment: number, pname: number): any; + uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; + sampleCoverage(value: number, invert: boolean): void; + depthFunc(func: number): void; + texParameterf(target: number, pname: number, param: number): void; + vertexAttrib3f(indx: number, x: number, y: number, z: number): void; + drawArrays(mode: number, first: number, count: number): void; + texParameteri(target: number, pname: number, param: number): void; + vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; + getShaderParameter(shader: WebGLShader, pname: number): any; + clearDepth(depth: number): void; + activeTexture(texture: number): void; + viewport(x: number, y: number, width: number, height: number): void; + detachShader(program: WebGLProgram, shader: WebGLShader): void; + uniform1f(location: WebGLUniformLocation, x: number): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + deleteBuffer(buffer: WebGLBuffer): void; + copyTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, x: number, y: number, width: number, height: number): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array): void; + stencilMaskSeparate(face: number, mask: number): void; + attachShader(program: WebGLProgram, shader: WebGLShader): void; + compileShader(shader: WebGLShader): void; + clearColor(red: number, green: number, blue: number, alpha: number): void; + isShader(shader: WebGLShader): boolean; + clearStencil(s: number): void; + framebufferRenderbuffer(target: number, attachment: number, renderbuffertarget: number, renderbuffer: WebGLRenderbuffer): void; + finish(): void; + uniform2f(location: WebGLUniformLocation, x: number, y: number): void; + renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; + uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; + getProgramInfoLog(program: WebGLProgram): string; + validateProgram(program: WebGLProgram): void; + isEnabled(cap: number): boolean; + vertexAttrib2f(indx: number, x: number, y: number): void; + isProgram(program: WebGLProgram): boolean; + createShader(type: number): WebGLShader; + bindRenderbuffer(target: number, renderbuffer: WebGLRenderbuffer): void; + uniform4iv(location: WebGLUniformLocation, v: Int32Array): void; + DEPTH_FUNC: number; + DEPTH_COMPONENT16: number; + REPLACE: number; + REPEAT: number; + VERTEX_ATTRIB_ARRAY_ENABLED: number; + FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + STENCIL_BUFFER_BIT: number; + RENDERER: number; + STENCIL_BACK_REF: number; + TEXTURE26: number; + RGB565: number; + DITHER: number; + CONSTANT_COLOR: number; + GENERATE_MIPMAP_HINT: number; + POINTS: number; + DECR: number; + INT_VEC3: number; + TEXTURE28: number; + ONE_MINUS_CONSTANT_ALPHA: number; + BACK: number; + RENDERBUFFER_STENCIL_SIZE: number; + UNPACK_FLIP_Y_WEBGL: number; + BLEND: number; + TEXTURE9: number; + ARRAY_BUFFER_BINDING: number; + MAX_VIEWPORT_DIMS: number; + INVALID_FRAMEBUFFER_OPERATION: number; + TEXTURE: number; + TEXTURE0: number; + TEXTURE31: number; + TEXTURE24: number; + HIGH_INT: number; + RENDERBUFFER_BINDING: number; + BLEND_COLOR: number; + FASTEST: number; + STENCIL_WRITEMASK: number; + ALIASED_POINT_SIZE_RANGE: number; + TEXTURE12: number; + DST_ALPHA: number; + BLEND_EQUATION_RGB: number; + FRAMEBUFFER_COMPLETE: number; + NEAREST_MIPMAP_NEAREST: number; + VERTEX_ATTRIB_ARRAY_SIZE: number; + TEXTURE3: number; + DEPTH_WRITEMASK: number; + CONTEXT_LOST_WEBGL: number; + INVALID_VALUE: number; + TEXTURE_MAG_FILTER: number; + ONE_MINUS_CONSTANT_COLOR: number; + ONE_MINUS_SRC_ALPHA: number; + TEXTURE_CUBE_MAP_POSITIVE_Z: number; + NOTEQUAL: number; + ALPHA: number; + DEPTH_STENCIL: number; + MAX_VERTEX_UNIFORM_VECTORS: number; + DEPTH_COMPONENT: number; + RENDERBUFFER_RED_SIZE: number; + TEXTURE20: number; + RED_BITS: number; + RENDERBUFFER_BLUE_SIZE: number; + SCISSOR_BOX: number; + VENDOR: number; + FRONT_AND_BACK: number; + CONSTANT_ALPHA: number; + VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + NEAREST: number; + CULL_FACE: number; + ALIASED_LINE_WIDTH_RANGE: number; + TEXTURE19: number; + FRONT: number; + DEPTH_CLEAR_VALUE: number; + GREEN_BITS: number; + TEXTURE29: number; + TEXTURE23: number; + MAX_RENDERBUFFER_SIZE: number; + STENCIL_ATTACHMENT: number; + TEXTURE27: number; + BOOL_VEC2: number; + OUT_OF_MEMORY: number; + MIRRORED_REPEAT: number; + POLYGON_OFFSET_UNITS: number; + TEXTURE_MIN_FILTER: number; + STENCIL_BACK_PASS_DEPTH_PASS: number; + LINE_LOOP: number; + FLOAT_MAT3: number; + TEXTURE14: number; + LINEAR: number; + RGB5_A1: number; + ONE_MINUS_SRC_COLOR: number; + SAMPLE_COVERAGE_INVERT: number; + DONT_CARE: number; + FRAMEBUFFER_BINDING: number; + RENDERBUFFER_ALPHA_SIZE: number; + STENCIL_REF: number; + ZERO: number; + DECR_WRAP: number; + SAMPLE_COVERAGE: number; + STENCIL_BACK_FUNC: number; + TEXTURE30: number; + VIEWPORT: number; + STENCIL_BITS: number; + FLOAT: number; + COLOR_WRITEMASK: number; + SAMPLE_COVERAGE_VALUE: number; + TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + STENCIL_BACK_FAIL: number; + FLOAT_MAT4: number; + UNSIGNED_SHORT_4_4_4_4: number; + TEXTURE6: number; + RENDERBUFFER_WIDTH: number; + RGBA4: number; + ALWAYS: number; + BLEND_EQUATION_ALPHA: number; + COLOR_BUFFER_BIT: number; + TEXTURE_CUBE_MAP: number; + DEPTH_BUFFER_BIT: number; + STENCIL_CLEAR_VALUE: number; + BLEND_EQUATION: number; + RENDERBUFFER_GREEN_SIZE: number; + NEAREST_MIPMAP_LINEAR: number; + VERTEX_ATTRIB_ARRAY_TYPE: number; + INCR_WRAP: number; + ONE_MINUS_DST_COLOR: number; + HIGH_FLOAT: number; + BYTE: number; + FRONT_FACE: number; + SAMPLE_ALPHA_TO_COVERAGE: number; + CCW: number; + TEXTURE13: number; + MAX_VERTEX_ATTRIBS: number; + MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + TEXTURE_WRAP_T: number; + UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + FLOAT_VEC2: number; + LUMINANCE: number; + GREATER: number; + INT_VEC2: number; + VALIDATE_STATUS: number; + FRAMEBUFFER: number; + FRAMEBUFFER_UNSUPPORTED: number; + TEXTURE5: number; + FUNC_SUBTRACT: number; + BLEND_DST_ALPHA: number; + SAMPLER_CUBE: number; + ONE_MINUS_DST_ALPHA: number; + LESS: number; + TEXTURE_CUBE_MAP_POSITIVE_X: number; + BLUE_BITS: number; + DEPTH_TEST: number; + VERTEX_ATTRIB_ARRAY_STRIDE: number; + DELETE_STATUS: number; + TEXTURE18: number; + POLYGON_OFFSET_FACTOR: number; + UNSIGNED_INT: number; + TEXTURE_2D: number; + DST_COLOR: number; + FLOAT_MAT2: number; + COMPRESSED_TEXTURE_FORMATS: number; + MAX_FRAGMENT_UNIFORM_VECTORS: number; + DEPTH_STENCIL_ATTACHMENT: number; + LUMINANCE_ALPHA: number; + CW: number; + VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + LINEAR_MIPMAP_LINEAR: number; + BUFFER_SIZE: number; + SAMPLE_BUFFERS: number; + TEXTURE15: number; + ACTIVE_TEXTURE: number; + VERTEX_SHADER: number; + TEXTURE22: number; + VERTEX_ATTRIB_ARRAY_POINTER: number; + INCR: number; + COMPILE_STATUS: number; + MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + TEXTURE7: number; + UNSIGNED_SHORT_5_5_5_1: number; + DEPTH_BITS: number; + RGBA: number; + TRIANGLE_STRIP: number; + COLOR_CLEAR_VALUE: number; + BROWSER_DEFAULT_WEBGL: number; + INVALID_ENUM: number; + SCISSOR_TEST: number; + LINE_STRIP: number; + FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + STENCIL_FUNC: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + RENDERBUFFER_HEIGHT: number; + TEXTURE8: number; + TRIANGLES: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + STENCIL_BACK_VALUE_MASK: number; + TEXTURE25: number; + RENDERBUFFER: number; + LEQUAL: number; + TEXTURE1: number; + STENCIL_INDEX8: number; + FUNC_ADD: number; + STENCIL_FAIL: number; + BLEND_SRC_ALPHA: number; + BOOL: number; + ALPHA_BITS: number; + LOW_INT: number; + TEXTURE10: number; + SRC_COLOR: number; + MAX_VARYING_VECTORS: number; + BLEND_DST_RGB: number; + TEXTURE_BINDING_CUBE_MAP: number; + STENCIL_INDEX: number; + TEXTURE_BINDING_2D: number; + MEDIUM_INT: number; + SHADER_TYPE: number; + POLYGON_OFFSET_FILL: number; + DYNAMIC_DRAW: number; + TEXTURE4: number; + STENCIL_BACK_PASS_DEPTH_FAIL: number; + STREAM_DRAW: number; + MAX_CUBE_MAP_TEXTURE_SIZE: number; + TEXTURE17: number; + TRIANGLE_FAN: number; + UNPACK_ALIGNMENT: number; + CURRENT_PROGRAM: number; + LINES: number; + INVALID_OPERATION: number; + FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + LINEAR_MIPMAP_NEAREST: number; + CLAMP_TO_EDGE: number; + RENDERBUFFER_DEPTH_SIZE: number; + TEXTURE_WRAP_S: number; + ELEMENT_ARRAY_BUFFER: number; + UNSIGNED_SHORT_5_6_5: number; + ACTIVE_UNIFORMS: number; + FLOAT_VEC3: number; + NO_ERROR: number; + ATTACHED_SHADERS: number; + DEPTH_ATTACHMENT: number; + TEXTURE11: number; + STENCIL_TEST: number; + ONE: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + STATIC_DRAW: number; + GEQUAL: number; + BOOL_VEC4: number; + COLOR_ATTACHMENT0: number; + PACK_ALIGNMENT: number; + MAX_TEXTURE_SIZE: number; + STENCIL_PASS_DEPTH_FAIL: number; + CULL_FACE_MODE: number; + TEXTURE16: number; + STENCIL_BACK_WRITEMASK: number; + SRC_ALPHA: number; + UNSIGNED_SHORT: number; + TEXTURE21: number; + FUNC_REVERSE_SUBTRACT: number; + SHADING_LANGUAGE_VERSION: number; + EQUAL: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + BOOL_VEC3: number; + SAMPLER_2D: number; + TEXTURE_CUBE_MAP_NEGATIVE_X: number; + MAX_TEXTURE_IMAGE_UNITS: number; + TEXTURE_CUBE_MAP_POSITIVE_Y: number; + RENDERBUFFER_INTERNAL_FORMAT: number; + STENCIL_VALUE_MASK: number; + ELEMENT_ARRAY_BUFFER_BINDING: number; + ARRAY_BUFFER: number; + DEPTH_RANGE: number; + NICEST: number; + ACTIVE_ATTRIBUTES: number; + NEVER: number; + FLOAT_VEC4: number; + CURRENT_VERTEX_ATTRIB: number; + STENCIL_PASS_DEPTH_PASS: number; + INVERT: number; + LINK_STATUS: number; + RGB: number; + INT_VEC4: number; + TEXTURE2: number; + UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + MEDIUM_FLOAT: number; + SRC_ALPHA_SATURATE: number; + BUFFER_USAGE: number; + SHORT: number; + NONE: number; + UNSIGNED_BYTE: number; + INT: number; + SUBPIXEL_BITS: number; + KEEP: number; + SAMPLES: number; + FRAGMENT_SHADER: number; + LINE_WIDTH: number; + BLEND_SRC_RGB: number; + LOW_FLOAT: number; + VERSION: number; +} +declare var WebGLRenderingContext: { + DEPTH_FUNC: number; + DEPTH_COMPONENT16: number; + REPLACE: number; + REPEAT: number; + VERTEX_ATTRIB_ARRAY_ENABLED: number; + FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + STENCIL_BUFFER_BIT: number; + RENDERER: number; + STENCIL_BACK_REF: number; + TEXTURE26: number; + RGB565: number; + DITHER: number; + CONSTANT_COLOR: number; + GENERATE_MIPMAP_HINT: number; + POINTS: number; + DECR: number; + INT_VEC3: number; + TEXTURE28: number; + ONE_MINUS_CONSTANT_ALPHA: number; + BACK: number; + RENDERBUFFER_STENCIL_SIZE: number; + UNPACK_FLIP_Y_WEBGL: number; + BLEND: number; + TEXTURE9: number; + ARRAY_BUFFER_BINDING: number; + MAX_VIEWPORT_DIMS: number; + INVALID_FRAMEBUFFER_OPERATION: number; + TEXTURE: number; + TEXTURE0: number; + TEXTURE31: number; + TEXTURE24: number; + HIGH_INT: number; + RENDERBUFFER_BINDING: number; + BLEND_COLOR: number; + FASTEST: number; + STENCIL_WRITEMASK: number; + ALIASED_POINT_SIZE_RANGE: number; + TEXTURE12: number; + DST_ALPHA: number; + BLEND_EQUATION_RGB: number; + FRAMEBUFFER_COMPLETE: number; + NEAREST_MIPMAP_NEAREST: number; + VERTEX_ATTRIB_ARRAY_SIZE: number; + TEXTURE3: number; + DEPTH_WRITEMASK: number; + CONTEXT_LOST_WEBGL: number; + INVALID_VALUE: number; + TEXTURE_MAG_FILTER: number; + ONE_MINUS_CONSTANT_COLOR: number; + ONE_MINUS_SRC_ALPHA: number; + TEXTURE_CUBE_MAP_POSITIVE_Z: number; + NOTEQUAL: number; + ALPHA: number; + DEPTH_STENCIL: number; + MAX_VERTEX_UNIFORM_VECTORS: number; + DEPTH_COMPONENT: number; + RENDERBUFFER_RED_SIZE: number; + TEXTURE20: number; + RED_BITS: number; + RENDERBUFFER_BLUE_SIZE: number; + SCISSOR_BOX: number; + VENDOR: number; + FRONT_AND_BACK: number; + CONSTANT_ALPHA: number; + VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + NEAREST: number; + CULL_FACE: number; + ALIASED_LINE_WIDTH_RANGE: number; + TEXTURE19: number; + FRONT: number; + DEPTH_CLEAR_VALUE: number; + GREEN_BITS: number; + TEXTURE29: number; + TEXTURE23: number; + MAX_RENDERBUFFER_SIZE: number; + STENCIL_ATTACHMENT: number; + TEXTURE27: number; + BOOL_VEC2: number; + OUT_OF_MEMORY: number; + MIRRORED_REPEAT: number; + POLYGON_OFFSET_UNITS: number; + TEXTURE_MIN_FILTER: number; + STENCIL_BACK_PASS_DEPTH_PASS: number; + LINE_LOOP: number; + FLOAT_MAT3: number; + TEXTURE14: number; + LINEAR: number; + RGB5_A1: number; + ONE_MINUS_SRC_COLOR: number; + SAMPLE_COVERAGE_INVERT: number; + DONT_CARE: number; + FRAMEBUFFER_BINDING: number; + RENDERBUFFER_ALPHA_SIZE: number; + STENCIL_REF: number; + ZERO: number; + DECR_WRAP: number; + SAMPLE_COVERAGE: number; + STENCIL_BACK_FUNC: number; + TEXTURE30: number; + VIEWPORT: number; + STENCIL_BITS: number; + FLOAT: number; + COLOR_WRITEMASK: number; + SAMPLE_COVERAGE_VALUE: number; + TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + STENCIL_BACK_FAIL: number; + FLOAT_MAT4: number; + UNSIGNED_SHORT_4_4_4_4: number; + TEXTURE6: number; + RENDERBUFFER_WIDTH: number; + RGBA4: number; + ALWAYS: number; + BLEND_EQUATION_ALPHA: number; + COLOR_BUFFER_BIT: number; + TEXTURE_CUBE_MAP: number; + DEPTH_BUFFER_BIT: number; + STENCIL_CLEAR_VALUE: number; + BLEND_EQUATION: number; + RENDERBUFFER_GREEN_SIZE: number; + NEAREST_MIPMAP_LINEAR: number; + VERTEX_ATTRIB_ARRAY_TYPE: number; + INCR_WRAP: number; + ONE_MINUS_DST_COLOR: number; + HIGH_FLOAT: number; + BYTE: number; + FRONT_FACE: number; + SAMPLE_ALPHA_TO_COVERAGE: number; + CCW: number; + TEXTURE13: number; + MAX_VERTEX_ATTRIBS: number; + MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + TEXTURE_WRAP_T: number; + UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + FLOAT_VEC2: number; + LUMINANCE: number; + GREATER: number; + INT_VEC2: number; + VALIDATE_STATUS: number; + FRAMEBUFFER: number; + FRAMEBUFFER_UNSUPPORTED: number; + TEXTURE5: number; + FUNC_SUBTRACT: number; + BLEND_DST_ALPHA: number; + SAMPLER_CUBE: number; + ONE_MINUS_DST_ALPHA: number; + LESS: number; + TEXTURE_CUBE_MAP_POSITIVE_X: number; + BLUE_BITS: number; + DEPTH_TEST: number; + VERTEX_ATTRIB_ARRAY_STRIDE: number; + DELETE_STATUS: number; + TEXTURE18: number; + POLYGON_OFFSET_FACTOR: number; + UNSIGNED_INT: number; + TEXTURE_2D: number; + DST_COLOR: number; + FLOAT_MAT2: number; + COMPRESSED_TEXTURE_FORMATS: number; + MAX_FRAGMENT_UNIFORM_VECTORS: number; + DEPTH_STENCIL_ATTACHMENT: number; + LUMINANCE_ALPHA: number; + CW: number; + VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + LINEAR_MIPMAP_LINEAR: number; + BUFFER_SIZE: number; + SAMPLE_BUFFERS: number; + TEXTURE15: number; + ACTIVE_TEXTURE: number; + VERTEX_SHADER: number; + TEXTURE22: number; + VERTEX_ATTRIB_ARRAY_POINTER: number; + INCR: number; + COMPILE_STATUS: number; + MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + TEXTURE7: number; + UNSIGNED_SHORT_5_5_5_1: number; + DEPTH_BITS: number; + RGBA: number; + TRIANGLE_STRIP: number; + COLOR_CLEAR_VALUE: number; + BROWSER_DEFAULT_WEBGL: number; + INVALID_ENUM: number; + SCISSOR_TEST: number; + LINE_STRIP: number; + FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + STENCIL_FUNC: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + RENDERBUFFER_HEIGHT: number; + TEXTURE8: number; + TRIANGLES: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + STENCIL_BACK_VALUE_MASK: number; + TEXTURE25: number; + RENDERBUFFER: number; + LEQUAL: number; + TEXTURE1: number; + STENCIL_INDEX8: number; + FUNC_ADD: number; + STENCIL_FAIL: number; + BLEND_SRC_ALPHA: number; + BOOL: number; + ALPHA_BITS: number; + LOW_INT: number; + TEXTURE10: number; + SRC_COLOR: number; + MAX_VARYING_VECTORS: number; + BLEND_DST_RGB: number; + TEXTURE_BINDING_CUBE_MAP: number; + STENCIL_INDEX: number; + TEXTURE_BINDING_2D: number; + MEDIUM_INT: number; + SHADER_TYPE: number; + POLYGON_OFFSET_FILL: number; + DYNAMIC_DRAW: number; + TEXTURE4: number; + STENCIL_BACK_PASS_DEPTH_FAIL: number; + STREAM_DRAW: number; + MAX_CUBE_MAP_TEXTURE_SIZE: number; + TEXTURE17: number; + TRIANGLE_FAN: number; + UNPACK_ALIGNMENT: number; + CURRENT_PROGRAM: number; + LINES: number; + INVALID_OPERATION: number; + FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + LINEAR_MIPMAP_NEAREST: number; + CLAMP_TO_EDGE: number; + RENDERBUFFER_DEPTH_SIZE: number; + TEXTURE_WRAP_S: number; + ELEMENT_ARRAY_BUFFER: number; + UNSIGNED_SHORT_5_6_5: number; + ACTIVE_UNIFORMS: number; + FLOAT_VEC3: number; + NO_ERROR: number; + ATTACHED_SHADERS: number; + DEPTH_ATTACHMENT: number; + TEXTURE11: number; + STENCIL_TEST: number; + ONE: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + STATIC_DRAW: number; + GEQUAL: number; + BOOL_VEC4: number; + COLOR_ATTACHMENT0: number; + PACK_ALIGNMENT: number; + MAX_TEXTURE_SIZE: number; + STENCIL_PASS_DEPTH_FAIL: number; + CULL_FACE_MODE: number; + TEXTURE16: number; + STENCIL_BACK_WRITEMASK: number; + SRC_ALPHA: number; + UNSIGNED_SHORT: number; + TEXTURE21: number; + FUNC_REVERSE_SUBTRACT: number; + SHADING_LANGUAGE_VERSION: number; + EQUAL: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + BOOL_VEC3: number; + SAMPLER_2D: number; + TEXTURE_CUBE_MAP_NEGATIVE_X: number; + MAX_TEXTURE_IMAGE_UNITS: number; + TEXTURE_CUBE_MAP_POSITIVE_Y: number; + RENDERBUFFER_INTERNAL_FORMAT: number; + STENCIL_VALUE_MASK: number; + ELEMENT_ARRAY_BUFFER_BINDING: number; + ARRAY_BUFFER: number; + DEPTH_RANGE: number; + NICEST: number; + ACTIVE_ATTRIBUTES: number; + NEVER: number; + FLOAT_VEC4: number; + CURRENT_VERTEX_ATTRIB: number; + STENCIL_PASS_DEPTH_PASS: number; + INVERT: number; + LINK_STATUS: number; + RGB: number; + INT_VEC4: number; + TEXTURE2: number; + UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + MEDIUM_FLOAT: number; + SRC_ALPHA_SATURATE: number; + BUFFER_USAGE: number; + SHORT: number; + NONE: number; + UNSIGNED_BYTE: number; + INT: number; + SUBPIXEL_BITS: number; + KEEP: number; + SAMPLES: number; + FRAGMENT_SHADER: number; + LINE_WIDTH: number; + BLEND_SRC_RGB: number; + LOW_FLOAT: number; + VERSION: number; +} + +interface WebGLProgram extends WebGLObject { +} + +interface OES_standard_derivatives { + FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; +} +declare var OES_standard_derivatives: { + FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; +} + +interface WebGLFramebuffer extends WebGLObject { +} + +interface WebGLShader extends WebGLObject { +} + +interface OES_texture_float_linear { +} + +interface WebGLObject { +} + +interface WebGLBuffer extends WebGLObject { +} + +interface WebGLShaderPrecisionFormat { + rangeMin: number; + rangeMax: number; + precision: number; +} + +interface EXT_texture_filter_anisotropic { + TEXTURE_MAX_ANISOTROPY_EXT: number; + MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; +} +declare var EXT_texture_filter_anisotropic: { + TEXTURE_MAX_ANISOTROPY_EXT: number; + MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; +} + + +///////////////////////////// +/// addEventListener overloads +///////////////////////////// + +interface HTMLElement { + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface Document { + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "msthumbnailclick", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stop", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mssitemodejumplistitemremoved", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectionchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "storagecommit", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msfullscreenerror", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msfullscreenchange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface Element { + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface MSNamespaceInfo { + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface Window { + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface SVGElement { + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface HTMLFrameElement { + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface XMLHttpRequest { + addEventListener(type: "timeout", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface HTMLFrameSetElement { + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface Screen { + addEventListener(type: "msorientationchange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface SVGSVGElement { + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "zoom", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface HTMLIFrameElement { + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface HTMLBodyElement { + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface XDomainRequest { + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeout", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface HTMLMarqueeElement { + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "bounce", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "start", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "finish", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface MSWindowExtensions { + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface HTMLMediaElement { + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface HTMLVideoElement { + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoOptimalLayoutChanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoFrameStepCompleted", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoFormatChanged", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface TextTrackCue { + addEventListener(type: "enter", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "exit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface WebSocket { + addEventListener(type: "open", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "close", listener: (ev: CloseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface XMLHttpRequestEventTarget { + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeout", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface AudioTrackList { + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: "removetrack", listener: (ev: any /*PluginArray*/) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface MSBaseReader { + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +interface IDBTransaction { + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface TextTrackList { + addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface IDBDatabase { + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface IDBOpenDBRequest { + addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "upgradeneeded", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blocked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface TextTrack { + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface IDBRequest { + addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface MessagePort { + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface ApplicationCache { + addEventListener(type: "downloading", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "updateready", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cached", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "obsolete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "checking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "noupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface AbstractWorker { + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +interface Worker { + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface GlobalEventHandlers { + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} +interface KeyOperation { + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface MSInputMethodContext { + addEventListener(type: "candidatewindowshow", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "candidatewindowhide", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: "candidatewindowupdate", listener: (ev: any) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface MSWebViewAsyncOperation { + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + +interface CryptoOperation { + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +} + + +declare function addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; +declare function addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; ///////////////////////////// diff --git a/_infrastructure/tests/typescript/0.9.5-beta/tsc b/_infrastructure/tests/typescript/0.9.7/tsc similarity index 100% rename from _infrastructure/tests/typescript/0.9.5-beta/tsc rename to _infrastructure/tests/typescript/0.9.7/tsc diff --git a/_infrastructure/tests/typescript/0.9.5-beta/tsc.js b/_infrastructure/tests/typescript/0.9.7/tsc.js similarity index 86% rename from _infrastructure/tests/typescript/0.9.5-beta/tsc.js rename to _infrastructure/tests/typescript/0.9.7/tsc.js index a31675a5a..01bea509c 100644 --- a/_infrastructure/tests/typescript/0.9.5-beta/tsc.js +++ b/_infrastructure/tests/typescript/0.9.7/tsc.js @@ -57,7 +57,7 @@ var TypeScript; Implementations_are_not_allowed_in_ambient_contexts: "Implementations are not allowed in ambient contexts.", declare_modifier_not_allowed_for_code_already_in_an_ambient_context: "'declare' modifier not allowed for code already in an ambient context.", Initializers_are_not_allowed_in_ambient_contexts: "Initializers are not allowed in ambient contexts.", - Parameter_property_declarations_can_only_be_used_in_constructors: "Parameter property declarations can only be used in constructors.", + Parameter_property_declarations_can_only_be_used_in_a_non_ambient_constructor_declaration: "Parameter property declarations can only be used in a non-ambient constructor declaration.", Function_implementation_expected: "Function implementation expected.", Constructor_implementation_expected: "Constructor implementation expected.", Function_overload_name_must_be_0: "Function overload name must be '{0}'.", @@ -97,13 +97,15 @@ var TypeScript; declare_modifier_not_allowed_on_import_declaration: "'declare' modifier not allowed on import declaration.", Function_overload_must_be_static: "Function overload must be static.", Function_overload_must_not_be_static: "Function overload must not be static.", - Parameter_property_declarations_cannot_be_used_in_an_ambient_context: "Parameter property declarations cannot be used in an ambient context.", Parameter_property_declarations_cannot_be_used_in_a_constructor_overload: "Parameter property declarations cannot be used in a constructor overload.", Invalid_reference_directive_syntax: "Invalid 'reference' directive syntax.", Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: "Octal literals are not available when targeting ECMAScript 5 and higher.", Accessors_are_not_allowed_in_ambient_contexts: "Accessors are not allowed in ambient contexts.", _0_modifier_cannot_appear_on_a_constructor_declaration: "'{0}' modifier cannot appear on a constructor declaration.", _0_modifier_cannot_appear_on_a_parameter: "'{0}' modifier cannot appear on a parameter.", + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: "Only a single variable declaration is allowed in a 'for...in' statement.", + Type_parameters_cannot_appear_on_a_constructor_declaration: "Type parameters cannot appear on a constructor declaration.", + Type_annotation_cannot_appear_on_a_constructor_declaration: "Type annotation cannot appear on a constructor declaration.", Duplicate_identifier_0: "Duplicate identifier '{0}'.", The_name_0_does_not_exist_in_the_current_scope: "The name '{0}' does not exist in the current scope.", The_name_0_does_not_refer_to_a_value: "The name '{0}' does not refer to a value.", @@ -199,14 +201,14 @@ var TypeScript; Could_not_find_symbol_0: "Could not find symbol '{0}'.", get_and_set_accessor_must_have_the_same_type: "'get' and 'set' accessor must have the same type.", this_cannot_be_referenced_in_current_location: "'this' cannot be referenced in current location.", - Static_methods_cannot_reference_class_type_parameters: "Static methods cannot reference class type parameters.", + Static_members_cannot_reference_class_type_parameters: "Static members cannot reference class type parameters.", Class_0_is_recursively_referenced_as_a_base_type_of_itself: "Class '{0}' is recursively referenced as a base type of itself.", Interface_0_is_recursively_referenced_as_a_base_type_of_itself: "Interface '{0}' is recursively referenced as a base type of itself.", super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.", super_cannot_be_referenced_in_non_derived_classes: "'super' cannot be referenced in non-derived classes.", A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.", Constructors_for_derived_classes_must_contain_a_super_call: "Constructors for derived classes must contain a 'super' call.", - Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors: "Super calls are not permitted outside constructors or in local functions inside constructors.", + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: "Super calls are not permitted outside constructors or in nested functions inside constructors.", _0_1_is_inaccessible: "'{0}.{1}' is inaccessible.", this_cannot_be_referenced_within_module_bodies: "'this' cannot be referenced within module bodies.", Invalid_expression_types_not_known_to_support_the_addition_operator: "Invalid '+' expression - types not known to support the addition operator.", @@ -219,11 +221,11 @@ var TypeScript; The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number: "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.", The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.", The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.", - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_a_subtype_of_the_Function_interface_type: "The right-hand side of an 'instanceof' expression must be of type 'any' or a subtype of the 'Function' interface type.", + The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.", Setters_cannot_return_a_value: "Setters cannot return a value.", Tried_to_query_type_of_uninitialized_module_0: "Tried to query type of uninitialized module '{0}'.", Tried_to_set_variable_type_to_uninitialized_module_type_0: "Tried to set variable type to uninitialized module type '{0}'.", - Function_0_declared_a_non_void_return_type_but_has_no_return_expression: "Function '{0}' declared a non-void return type, but has no return expression.", + Type_0_does_not_have_type_parameters: "Type '{0}' does not have type parameters.", Getters_must_return_a_value: "Getters must return a value.", Getter_and_setter_accessors_do_not_agree_in_visibility: "Getter and setter accessors do not agree in visibility.", Invalid_left_hand_side_of_assignment_expression: "Invalid left-hand side of assignment expression.", @@ -250,7 +252,7 @@ var TypeScript; Overload_signatures_must_all_be_exported_or_not_exported: "Overload signatures must all be exported or not exported.", Overload_signatures_must_all_be_ambient_or_non_ambient: "Overload signatures must all be ambient or non-ambient.", Overload_signatures_must_all_be_optional_or_required: "Overload signatures must all be optional or required.", - Specialized_overload_signature_is_not_subtype_of_any_non_specialized_signature: "Specialized overload signature is not subtype of any non-specialized signature.", + Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: "Specialized overload signature is not assignable to any non-specialized signature.", this_cannot_be_referenced_in_constructor_arguments: "'this' cannot be referenced in constructor arguments.", Instance_member_cannot_be_accessed_off_a_class: "Instance member cannot be accessed off a class.", Untyped_function_calls_may_not_accept_type_arguments: "Untyped function calls may not accept type arguments.", @@ -261,14 +263,14 @@ var TypeScript; Export_assignments_may_only_be_used_at_the_top_level_of_external_modules: "Export assignments may only be used at the top-level of external modules.", Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules: "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.", Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword: "Only public methods of the base class are accessible via the 'super' keyword.", - Numeric_indexer_type_0_must_be_a_subtype_of_string_indexer_type_1: "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}'.", - Numeric_indexer_type_0_must_be_a_subtype_of_string_indexer_type_1_NL_2: "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}':{NL}{2}", - All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type_0: "All numerically named properties must be subtypes of numeric indexer type '{0}'.", - All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type_0_NL_1: "All numerically named properties must be subtypes of numeric indexer type '{0}':{NL}{1}", - All_named_properties_must_be_subtypes_of_string_indexer_type_0: "All named properties must be subtypes of string indexer type '{0}'.", - All_named_properties_must_be_subtypes_of_string_indexer_type_0_NL_1: "All named properties must be subtypes of string indexer type '{0}':{NL}{1}", + Numeric_indexer_type_0_must_be_assignable_to_string_indexer_type_1: "Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.", + Numeric_indexer_type_0_must_be_assignable_to_string_indexer_type_1_NL_2: "Numeric indexer type '{0}' must be assignable to string indexer type '{1}':{NL}{2}", + All_numerically_named_properties_must_be_assignable_to_numeric_indexer_type_0: "All numerically named properties must be assignable to numeric indexer type '{0}'.", + All_numerically_named_properties_must_be_assignable_to_numeric_indexer_type_0_NL_1: "All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}", + All_named_properties_must_be_assignable_to_string_indexer_type_0: "All named properties must be assignable to string indexer type '{0}'.", + All_named_properties_must_be_assignable_to_string_indexer_type_0_NL_1: "All named properties must be assignable to string indexer type '{0}':{NL}{1}", Generic_type_references_must_include_all_type_arguments: "Generic type references must include all type arguments.", - Default_arguments_are_not_allowed_in_an_overload_parameter: "Default arguments are not allowed in an overload parameter.", + Default_arguments_are_only_allowed_in_implementation: "Default arguments are only allowed in implementation.", Overloads_cannot_differ_only_by_return_type: "Overloads cannot differ only by return type.", Function_expression_declared_a_non_void_return_type_but_has_no_return_expression: "Function expression declared a non-void return type, but has no return expression.", Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules: "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.", @@ -280,7 +282,7 @@ var TypeScript; Exported_import_declaration_0_is_assigned_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.", Exported_import_declaration_0_is_assigned_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.", Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.", - Type_reference_0_in_extends_clause_does_not_reference_constructor_function_for_1: "Type reference '{0}' in extends clause does not reference constructor function for '{1}'.", + Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_1: "Type name '{0}' in extends clause does not reference constructor function for '{1}'.", Internal_module_reference_0_in_import_declaration_does_not_reference_module_instance_for_1: "Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.", Module_0_cannot_merge_with_previous_declaration_of_1_in_a_different_file_2: "Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.", Interface_0_cannot_simultaneously_extend_types_1_and_2_NL_3: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}", @@ -323,6 +325,13 @@ var TypeScript; Type_of_conditional_0_must_be_identical_to_1_or_2: "Type of conditional '{0}' must be identical to '{1}' or '{2}'.", Type_of_conditional_0_must_be_identical_to_1_2_or_3: "Type of conditional '{0}' must be identical to '{1}', '{2}' or '{3}'.", Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.", + Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list.", + Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.", + Parameter_0_cannot_be_referenced_in_its_initializer: "Parameter '{0}' cannot be referenced in its initializer.", + Duplicate_string_index_signature: "Duplicate string index signature.", + Duplicate_number_index_signature: "Duplicate number index signature.", + All_declarations_of_an_interface_must_have_identical_type_parameters: "All declarations of an interface must have identical type parameters.", + Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter: "Expression resolves to variable declaration '_i' that compiler uses to initialize rest parameter.", Type_0_is_missing_property_1_from_type_2: "Type '{0}' is missing property '{1}' from type '{2}'.", Types_of_property_0_of_types_1_and_2_are_incompatible: "Types of property '{0}' of types '{1}' and '{2}' are incompatible.", Types_of_property_0_of_types_1_and_2_are_incompatible_NL_3: "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}", @@ -347,20 +356,23 @@ var TypeScript; Types_of_static_property_0_of_class_1_and_class_2_are_incompatible_NL_3: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}", Type_reference_cannot_refer_to_container_0: "Type reference cannot refer to container '{0}'.", Type_reference_must_refer_to_type: "Type reference must refer to type.", - Enums_with_multiple_declarations_must_provide_an_initializer_for_the_first_enum_element: "Enums with multiple declarations must provide an initializer for the first enum element.", + In_enums_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_the_first_enum_element: "In enums with multiple declarations only one declaration can omit an initializer for the first enum element.", _0_overload_s: " (+ {0} overload(s))", Variable_declaration_cannot_have_the_same_name_as_an_import_declaration: "Variable declaration cannot have the same name as an import declaration.", Signature_expected_0_type_arguments_got_1_instead: "Signature expected {0} type arguments, got {1} instead.", Property_0_defined_as_optional_in_type_1_but_is_required_in_type_2: "Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.", - Types_0_and_1_originating_in_inifinitely_expanding_type_reference_do_not_refer_to_same_named_type: "Types '{0}' and '{1}' originating in inifinitely expanding type reference do not refer to same named type.", - Types_0_and_1_originating_in_inifinitely_expanding_type_reference_have_incompatible_type_arguments: "Types '{0}' and '{1}' originating in inifinitely expanding type reference have incompatible type arguments.", - Types_0_and_1_originating_in_inifinitely_expanding_type_reference_have_incompatible_type_arguments_NL_2: "Types '{0}' and '{1}' originating in inifinitely expanding type reference have incompatible type arguments:{NL}{2}", - Types_of_property_0_of_types_1_and_2_are_not_identical: "Types of property '{0}' of types '{1}' and '{2}' are not identical.", + Types_0_and_1_originating_in_infinitely_expanding_type_reference_do_not_refer_to_same_named_type: "Types '{0}' and '{1}' originating in infinitely expanding type reference do not refer to same named type.", + Types_0_and_1_originating_in_infinitely_expanding_type_reference_have_incompatible_type_arguments: "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments.", + Types_0_and_1_originating_in_infinitely_expanding_type_reference_have_incompatible_type_arguments_NL_2: "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}", + Named_properties_0_of_types_1_and_2_are_not_identical: "Named properties '{0}' of types '{1}' and '{2}' are not identical.", Types_of_string_indexer_of_types_0_and_1_are_not_identical: "Types of string indexer of types '{0}' and '{1}' are not identical.", Types_of_number_indexer_of_types_0_and_1_are_not_identical: "Types of number indexer of types '{0}' and '{1}' are not identical.", - Type_of_number_indexer_in_type_0_is_not_a_subtype_of_string_indexer_type_in_type_1_NL_2: "Type of number indexer in type '{0}' is not a subtype of string indexer type in type '{1}'.{NL}{2}", - Type_of_property_0_in_type_1_is_not_a_subtype_of_string_indexer_type_in_type_2_NL_3: "Type of property '{0}' in type '{1}' is not a subtype of string indexer type in type '{2}'.{NL}{3}", - Type_of_property_0_in_type_1_is_not_a_subtype_of_number_indexer_type_in_type_2_NL_3: "Type of property '{0}' in type '{1}' is not a subtype of number indexer type in type '{2}'.{NL}{3}", + Type_of_number_indexer_in_type_0_is_not_assignable_to_string_indexer_type_in_type_1_NL_2: "Type of number indexer in type '{0}' is not assignable to string indexer type in type '{1}'.{NL}{2}", + Type_of_property_0_in_type_1_is_not_assignable_to_string_indexer_type_in_type_2_NL_3: "Type of property '{0}' in type '{1}' is not assignable to string indexer type in type '{2}'.{NL}{3}", + Type_of_property_0_in_type_1_is_not_assignable_to_number_indexer_type_in_type_2_NL_3: "Type of property '{0}' in type '{1}' is not assignable to number indexer type in type '{2}'.{NL}{3}", + Static_property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Static property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.", + Static_property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Static property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.", + Types_0_and_1_define_static_property_2_as_private: "Types '{0}' and '{1}' define static property '{2}' as private.", Current_host_does_not_support_0_option: "Current host does not support '{0}' option.", ECMAScript_target_version_0_not_supported_Specify_a_valid_target_version_1_default_or_2: "ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'", Module_code_generation_0_not_supported: "Module code generation '{0}' not supported.", @@ -420,6 +432,7 @@ var TypeScript; DIRECTORY: "DIRECTORY", NUMBER: "NUMBER", Specify_the_codepage_to_use_when_opening_source_files: "Specify the codepage to use when opening source files.", + Additional_locations: "Additional locations:", This_version_of_the_Javascript_runtime_does_not_support_the_0_function: "This version of the Javascript runtime does not support the '{0}' function.", Unknown_rule: "Unknown rule.", Invalid_line_number_0: "Invalid line number ({0})", @@ -435,7 +448,9 @@ var TypeScript; Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.", Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.", Array_Literal_implicitly_has_an_any_type_from_widening: "Array Literal implicitly has an 'any' type from widening.", - _0_which_lacks_get_accessor_and_parameter_type_annotation_on_set_accessor_implicitly_has_an_any_type: "'{0}', which lacks 'get' accessor and parameter type annotation on 'set' accessor, implicitly has an 'any' type." + _0_which_lacks_get_accessor_and_parameter_type_annotation_on_set_accessor_implicitly_has_an_any_type: "'{0}', which lacks 'get' accessor and parameter type annotation on 'set' accessor, implicitly has an 'any' type.", + Index_signature_of_object_type_implicitly_has_an_any_type: "Index signature of object type implicitly has an 'any' type.", + Object_literal_s_property_0_implicitly_has_an_any_type_from_widening: "Object literal's property '{0}' implicitly has an 'any' type from widening." }; })(TypeScript || (TypeScript = {})); var TypeScript; @@ -959,20 +974,64 @@ var TypeScript; })(); TypeScript.Debug = Debug; })(TypeScript || (TypeScript = {})); +var __extends = this.__extends || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; var TypeScript; (function (TypeScript) { TypeScript.LocalizedDiagnosticMessages = null; - var Diagnostic = (function () { - function Diagnostic(fileName, lineMap, start, length, diagnosticKey, arguments) { - if (typeof arguments === "undefined") { arguments = null; } - this._diagnosticKey = diagnosticKey; - this._arguments = (arguments && arguments.length > 0) ? arguments : null; + var Location = (function () { + function Location(fileName, lineMap, start, length) { this._fileName = fileName; this._lineMap = lineMap; this._start = start; this._length = length; } + Location.prototype.fileName = function () { + return this._fileName; + }; + + Location.prototype.lineMap = function () { + return this._lineMap; + }; + + Location.prototype.line = function () { + return this._lineMap ? this._lineMap.getLineNumberFromPosition(this.start()) : 0; + }; + + Location.prototype.character = function () { + return this._lineMap ? this._lineMap.getLineAndCharacterFromPosition(this.start()).character() : 0; + }; + + Location.prototype.start = function () { + return this._start; + }; + + Location.prototype.length = function () { + return this._length; + }; + + Location.equals = function (location1, location2) { + return location1._fileName === location2._fileName && location1._start === location2._start && location1._length === location2._length; + }; + return Location; + })(); + TypeScript.Location = Location; + + var Diagnostic = (function (_super) { + __extends(Diagnostic, _super); + function Diagnostic(fileName, lineMap, start, length, diagnosticKey, _arguments, additionalLocations) { + if (typeof _arguments === "undefined") { _arguments = null; } + if (typeof additionalLocations === "undefined") { additionalLocations = null; } + _super.call(this, fileName, lineMap, start, length); + this._diagnosticKey = diagnosticKey; + this._arguments = (_arguments && _arguments.length > 0) ? _arguments : null; + this._additionalLocations = (additionalLocations && additionalLocations.length > 0) ? additionalLocations : null; + } Diagnostic.prototype.toJSON = function (key) { var result = {}; result.start = this.start(); @@ -980,34 +1039,14 @@ var TypeScript; result.diagnosticCode = this._diagnosticKey; - var arguments = this.arguments(); - if (arguments && arguments.length > 0) { - result.arguments = arguments; + var _arguments = this.arguments(); + if (_arguments && _arguments.length > 0) { + result.arguments = _arguments; } return result; }; - Diagnostic.prototype.fileName = function () { - return this._fileName; - }; - - Diagnostic.prototype.line = function () { - return this._lineMap ? this._lineMap.getLineNumberFromPosition(this.start()) : 0; - }; - - Diagnostic.prototype.character = function () { - return this._lineMap ? this._lineMap.getLineAndCharacterFromPosition(this.start()).character() : 0; - }; - - Diagnostic.prototype.start = function () { - return this._start; - }; - - Diagnostic.prototype.length = function () { - return this._length; - }; - Diagnostic.prototype.diagnosticKey = function () { return this._diagnosticKey; }; @@ -1025,11 +1064,11 @@ var TypeScript; }; Diagnostic.prototype.additionalLocations = function () { - return []; + return this._additionalLocations || []; }; Diagnostic.equals = function (diagnostic1, diagnostic2) { - return diagnostic1._fileName === diagnostic2._fileName && diagnostic1._start === diagnostic2._start && diagnostic1._length === diagnostic2._length && diagnostic1._diagnosticKey === diagnostic2._diagnosticKey && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { + return Location.equals(diagnostic1, diagnostic2) && diagnostic1._diagnosticKey === diagnostic2._diagnosticKey && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { return v1 === v2; }); }; @@ -1038,7 +1077,7 @@ var TypeScript; return getDiagnosticInfoFromKey(this.diagnosticKey()); }; return Diagnostic; - })(); + })(Location); TypeScript.Diagnostic = Diagnostic; function newLine() { @@ -1051,7 +1090,7 @@ var TypeScript; var regex = /\{(\d+)\}/g; var match; - while ((match = regex.exec(diagnostic)) != null) { + while (match = regex.exec(diagnostic)) { var val = parseInt(match[1]); if (!isNaN(val) && val > largest) { largest = val; @@ -1216,7 +1255,7 @@ var TypeScript; numberOfCharsLeft -= 2; } - if (numberOfCharsLeft == 1) { + if (numberOfCharsLeft === 1) { h ^= key.charCodeAt(index); h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); } @@ -2252,7 +2291,7 @@ var TypeScript; "code": 1039, "category": 1 /* Error */ }, - "Parameter property declarations can only be used in constructors.": { + "Parameter property declarations can only be used in a non-ambient constructor declaration.": { "code": 1040, "category": 1 /* Error */ }, @@ -2412,10 +2451,6 @@ var TypeScript; "code": 1081, "category": 1 /* Error */ }, - "Parameter property declarations cannot be used in an ambient context.": { - "code": 1082, - "category": 1 /* Error */ - }, "Parameter property declarations cannot be used in a constructor overload.": { "code": 1083, "category": 1 /* Error */ @@ -2440,6 +2475,18 @@ var TypeScript; "code": 1090, "category": 1 /* Error */ }, + "Only a single variable declaration is allowed in a 'for...in' statement.": { + "code": 1091, + "category": 1 /* Error */ + }, + "Type parameters cannot appear on a constructor declaration.": { + "code": 1091, + "category": 1 /* Error */ + }, + "Type annotation cannot appear on a constructor declaration.": { + "code": 1092, + "category": 1 /* Error */ + }, "Duplicate identifier '{0}'.": { "code": 2000, "category": 1 /* Error */ @@ -2820,7 +2867,7 @@ var TypeScript; "code": 2097, "category": 1 /* Error */ }, - "Static methods cannot reference class type parameters.": { + "Static members cannot reference class type parameters.": { "code": 2099, "category": 1 /* Error */ }, @@ -2848,7 +2895,7 @@ var TypeScript; "code": 2105, "category": 1 /* Error */ }, - "Super calls are not permitted outside constructors or in local functions inside constructors.": { + "Super calls are not permitted outside constructors or in nested functions inside constructors.": { "code": 2106, "category": 1 /* Error */ }, @@ -2900,7 +2947,7 @@ var TypeScript; "code": 2120, "category": 1 /* Error */ }, - "The right-hand side of an 'instanceof' expression must be of type 'any' or a subtype of the 'Function' interface type.": { + "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.": { "code": 2121, "category": 1 /* Error */ }, @@ -2916,7 +2963,7 @@ var TypeScript; "code": 2124, "category": 1 /* Error */ }, - "Function '{0}' declared a non-void return type, but has no return expression.": { + "Type '{0}' does not have type parameters.": { "code": 2125, "category": 1 /* Error */ }, @@ -3024,7 +3071,7 @@ var TypeScript; "code": 2153, "category": 1 /* Error */ }, - "Specialized overload signature is not subtype of any non-specialized signature.": { + "Specialized overload signature is not assignable to any non-specialized signature.": { "code": 2154, "category": 1 /* Error */ }, @@ -3068,27 +3115,27 @@ var TypeScript; "code": 2166, "category": 1 /* Error */ }, - "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}'.": { + "Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.": { "code": 2167, "category": 1 /* Error */ }, - "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}':{NL}{2}": { + "Numeric indexer type '{0}' must be assignable to string indexer type '{1}':{NL}{2}": { "code": 2168, "category": 1 /* Error */ }, - "All numerically named properties must be subtypes of numeric indexer type '{0}'.": { + "All numerically named properties must be assignable to numeric indexer type '{0}'.": { "code": 2169, "category": 1 /* Error */ }, - "All numerically named properties must be subtypes of numeric indexer type '{0}':{NL}{1}": { + "All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}": { "code": 2170, "category": 1 /* Error */ }, - "All named properties must be subtypes of string indexer type '{0}'.": { + "All named properties must be assignable to string indexer type '{0}'.": { "code": 2171, "category": 1 /* Error */ }, - "All named properties must be subtypes of string indexer type '{0}':{NL}{1}": { + "All named properties must be assignable to string indexer type '{0}':{NL}{1}": { "code": 2172, "category": 1 /* Error */ }, @@ -3096,7 +3143,7 @@ var TypeScript; "code": 2173, "category": 1 /* Error */ }, - "Default arguments are not allowed in an overload parameter.": { + "Default arguments are only allowed in implementation.": { "code": 2174, "category": 1 /* Error */ }, @@ -3144,7 +3191,7 @@ var TypeScript; "code": 2185, "category": 1 /* Error */ }, - "Type reference '{0}' in extends clause does not reference constructor function for '{1}'.": { + "Type name '{0}' in extends clause does not reference constructor function for '{1}'.": { "code": 2186, "category": 1 /* Error */ }, @@ -3316,6 +3363,34 @@ var TypeScript; "code": 2228, "category": 1 /* Error */ }, + "Constraint of a type parameter cannot reference any type parameter from the same type parameter list.": { + "code": 2229, + "category": 1 /* Error */ + }, + "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.": { + "code": 2230, + "category": 1 /* Error */ + }, + "Parameter '{0}' cannot be referenced in its initializer.": { + "code": 2231, + "category": 1 /* Error */ + }, + "Duplicate string index signature.": { + "code": 2232, + "category": 1 /* Error */ + }, + "Duplicate number index signature.": { + "code": 2233, + "category": 1 /* Error */ + }, + "All declarations of an interface must have identical type parameters.": { + "code": 2234, + "category": 1 /* Error */ + }, + "Expression resolves to variable declaration '_i' that compiler uses to initialize rest parameter.": { + "code": 2235, + "category": 1 /* Error */ + }, "Type '{0}' is missing property '{1}' from type '{2}'.": { "code": 4000, "category": 3 /* NoPrefix */ @@ -3412,7 +3487,7 @@ var TypeScript; "code": 4023, "category": 1 /* Error */ }, - "Enums with multiple declarations must provide an initializer for the first enum element.": { + "In enums with multiple declarations only one declaration can omit an initializer for the first enum element.": { "code": 4024, "category": 1 /* Error */ }, @@ -3432,19 +3507,19 @@ var TypeScript; "code": 4028, "category": 3 /* NoPrefix */ }, - "Types '{0}' and '{1}' originating in inifinitely expanding type reference do not refer to same named type.": { + "Types '{0}' and '{1}' originating in infinitely expanding type reference do not refer to same named type.": { "code": 4029, "category": 3 /* NoPrefix */ }, - "Types '{0}' and '{1}' originating in inifinitely expanding type reference have incompatible type arguments.": { + "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments.": { "code": 4030, "category": 3 /* NoPrefix */ }, - "Types '{0}' and '{1}' originating in inifinitely expanding type reference have incompatible type arguments:{NL}{2}": { + "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}": { "code": 4031, "category": 3 /* NoPrefix */ }, - "Types of property '{0}' of types '{1}' and '{2}' are not identical.": { + "Named properties '{0}' of types '{1}' and '{2}' are not identical.": { "code": 4032, "category": 3 /* NoPrefix */ }, @@ -3456,18 +3531,30 @@ var TypeScript; "code": 4034, "category": 3 /* NoPrefix */ }, - "Type of number indexer in type '{0}' is not a subtype of string indexer type in type '{1}'.{NL}{2}": { + "Type of number indexer in type '{0}' is not assignable to string indexer type in type '{1}'.{NL}{2}": { "code": 4035, "category": 3 /* NoPrefix */ }, - "Type of property '{0}' in type '{1}' is not a subtype of string indexer type in type '{2}'.{NL}{3}": { + "Type of property '{0}' in type '{1}' is not assignable to string indexer type in type '{2}'.{NL}{3}": { "code": 4036, "category": 3 /* NoPrefix */ }, - "Type of property '{0}' in type '{1}' is not a subtype of number indexer type in type '{2}'.{NL}{3}": { + "Type of property '{0}' in type '{1}' is not assignable to number indexer type in type '{2}'.{NL}{3}": { "code": 4037, "category": 3 /* NoPrefix */ }, + "Static property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { + "code": 4038, + "category": 3 /* NoPrefix */ + }, + "Static property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { + "code": 4039, + "category": 3 /* NoPrefix */ + }, + "Types '{0}' and '{1}' define static property '{2}' as private.": { + "code": 4040, + "category": 3 /* NoPrefix */ + }, "Current host does not support '{0}' option.": { "code": 5001, "category": 1 /* Error */ @@ -3704,6 +3791,10 @@ var TypeScript; "code": 6040, "category": 2 /* Message */ }, + "Additional locations:": { + "code": 6041, + "category": 2 /* Message */ + }, "This version of the Javascript runtime does not support the '{0}' function.": { "code": 7000, "category": 1 /* Error */ @@ -3767,6 +3858,14 @@ var TypeScript; "'{0}', which lacks 'get' accessor and parameter type annotation on 'set' accessor, implicitly has an 'any' type.": { "code": 7016, "category": 1 /* Error */ + }, + "Index signature of object type implicitly has an 'any' type.": { + "code": 7017, + "category": 1 /* Error */ + }, + "Object literal's property '{0}' implicitly has an 'any' type from widening.": { + "code": 7018, + "category": 1 /* Error */ } }; })(TypeScript || (TypeScript = {})); @@ -3943,12 +4042,6 @@ var TypeScript; })(TypeScript.LineMap1 || (TypeScript.LineMap1 = {})); var LineMap1 = TypeScript.LineMap1; })(TypeScript || (TypeScript = {})); -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; var TypeScript; (function (TypeScript) { (function (TextFactory) { @@ -6082,40 +6175,47 @@ var TypeScript; var end = this.slidingWindow.absoluteIndex(); var trailingTriviaInfo = this.scanTriviaInfo(diagnostics, true); + var fullEnd = this.slidingWindow.absoluteIndex(); var isVariableWidthKeyword = (kindAndFlags & -2147483648 /* IsVariableWidthKeyword */) !== 0; var kind = kindAndFlags & ~-2147483648 /* IsVariableWidthKeyword */; - var token = this.createToken(fullStart, leadingTriviaInfo, start, kind, end, trailingTriviaInfo, isVariableWidthKeyword); + var token = this.createToken(fullStart, leadingTriviaInfo, start, kind, end, fullEnd, trailingTriviaInfo, isVariableWidthKeyword); return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; }; - Scanner.prototype.createToken = function (fullStart, leadingTriviaInfo, start, kind, end, trailingTriviaInfo, isVariableWidthKeyword) { + Scanner.prototype.createToken = function (fullStart, leadingTriviaInfo, start, kind, end, fullEnd, trailingTriviaInfo, isVariableWidthKeyword) { if (!isVariableWidthKeyword && kind >= 15 /* FirstFixedWidth */) { if (leadingTriviaInfo === 0) { if (trailingTriviaInfo === 0) { return new TypeScript.Syntax.FixedWidthTokenWithNoTrivia(kind); } else { - return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(this.text, fullStart, kind, trailingTriviaInfo); + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); } } else if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(this.text, fullStart, kind, leadingTriviaInfo); + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); } else { - return new TypeScript.Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia(this.text, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo); + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo); } } else { var width = end - start; + + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + if (leadingTriviaInfo === 0) { if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.VariableWidthTokenWithNoTrivia(this.text, fullStart, kind, width); + return new TypeScript.Syntax.VariableWidthTokenWithNoTrivia(fullText, kind); } else { - return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(this.text, fullStart, kind, width, trailingTriviaInfo); + return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); } } else if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(this.text, fullStart, kind, leadingTriviaInfo, width); + return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); } else { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(this.text, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo); + return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo); } } }; @@ -8606,8 +8706,8 @@ var TypeScript; NormalModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { return new TypeScript.ExpressionStatementSyntax(expression, semicolonToken, false); }; - NormalModeFactory.prototype.constructorDeclaration = function (modifiers, constructorKeyword, parameterList, block, semicolonToken) { - return new TypeScript.ConstructorDeclarationSyntax(modifiers, constructorKeyword, parameterList, block, semicolonToken, false); + NormalModeFactory.prototype.constructorDeclaration = function (modifiers, constructorKeyword, callSignature, block, semicolonToken) { + return new TypeScript.ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, false); }; NormalModeFactory.prototype.memberFunctionDeclaration = function (modifiers, propertyName, callSignature, block, semicolonToken) { return new TypeScript.MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, false); @@ -8868,8 +8968,8 @@ var TypeScript; StrictModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { return new TypeScript.ExpressionStatementSyntax(expression, semicolonToken, true); }; - StrictModeFactory.prototype.constructorDeclaration = function (modifiers, constructorKeyword, parameterList, block, semicolonToken) { - return new TypeScript.ConstructorDeclarationSyntax(modifiers, constructorKeyword, parameterList, block, semicolonToken, true); + StrictModeFactory.prototype.constructorDeclaration = function (modifiers, constructorKeyword, callSignature, block, semicolonToken) { + return new TypeScript.ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, true); }; StrictModeFactory.prototype.memberFunctionDeclaration = function (modifiers, propertyName, callSignature, block, semicolonToken) { return new TypeScript.MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, true); @@ -9495,12 +9595,13 @@ var TypeScript; result.parsedInStrictMode = true; } + var thisAsIndexable = this; for (var i = 0, n = this.childCount(); i < n; i++) { var value = this.childAt(i); if (value) { for (var name in this) { - if (value === this[name]) { + if (value === thisAsIndexable[name]) { result[name] = value; break; } @@ -12799,12 +12900,13 @@ var TypeScript; var ArgumentListSyntax = (function (_super) { __extends(ArgumentListSyntax, _super); - function ArgumentListSyntax(typeArgumentList, openParenToken, arguments, closeParenToken, parsedInStrictMode) { + function ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, parsedInStrictMode) { _super.call(this, parsedInStrictMode); this.typeArgumentList = typeArgumentList; this.openParenToken = openParenToken; - this.arguments = arguments; this.closeParenToken = closeParenToken; + + this.arguments = _arguments; } ArgumentListSyntax.prototype.accept = function (visitor) { return visitor.visitArgumentList(this); @@ -14038,11 +14140,11 @@ var TypeScript; var ConstructorDeclarationSyntax = (function (_super) { __extends(ConstructorDeclarationSyntax, _super); - function ConstructorDeclarationSyntax(modifiers, constructorKeyword, parameterList, block, semicolonToken, parsedInStrictMode) { + function ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, parsedInStrictMode) { _super.call(this, parsedInStrictMode); this.modifiers = modifiers; this.constructorKeyword = constructorKeyword; - this.parameterList = parameterList; + this.callSignature = callSignature; this.block = block; this.semicolonToken = semicolonToken; } @@ -14065,7 +14167,7 @@ var TypeScript; case 1: return this.constructorKeyword; case 2: - return this.parameterList; + return this.callSignature; case 3: return this.block; case 4: @@ -14079,20 +14181,20 @@ var TypeScript; return true; }; - ConstructorDeclarationSyntax.prototype.update = function (modifiers, constructorKeyword, parameterList, block, semicolonToken) { - if (this.modifiers === modifiers && this.constructorKeyword === constructorKeyword && this.parameterList === parameterList && this.block === block && this.semicolonToken === semicolonToken) { + ConstructorDeclarationSyntax.prototype.update = function (modifiers, constructorKeyword, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.constructorKeyword === constructorKeyword && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { return this; } - return new ConstructorDeclarationSyntax(modifiers, constructorKeyword, parameterList, block, semicolonToken, this.parsedInStrictMode()); + return new ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, this.parsedInStrictMode()); }; - ConstructorDeclarationSyntax.create = function (constructorKeyword, parameterList) { - return new ConstructorDeclarationSyntax(TypeScript.Syntax.emptyList, constructorKeyword, parameterList, null, null, false); + ConstructorDeclarationSyntax.create = function (constructorKeyword, callSignature) { + return new ConstructorDeclarationSyntax(TypeScript.Syntax.emptyList, constructorKeyword, callSignature, null, null, false); }; ConstructorDeclarationSyntax.create1 = function () { - return new ConstructorDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(62 /* ConstructorKeyword */), ParameterListSyntax.create1(), null, null, false); + return new ConstructorDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(62 /* ConstructorKeyword */), CallSignatureSyntax.create1(), null, null, false); }; ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { @@ -14104,7 +14206,7 @@ var TypeScript; }; ConstructorDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.constructorKeyword, this.parameterList, this.block, this.semicolonToken); + return this.update(modifiers, this.constructorKeyword, this.callSignature, this.block, this.semicolonToken); }; ConstructorDeclarationSyntax.prototype.withModifier = function (modifier) { @@ -14112,19 +14214,19 @@ var TypeScript; }; ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { - return this.update(this.modifiers, constructorKeyword, this.parameterList, this.block, this.semicolonToken); + return this.update(this.modifiers, constructorKeyword, this.callSignature, this.block, this.semicolonToken); }; - ConstructorDeclarationSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.constructorKeyword, parameterList, this.block, this.semicolonToken); + ConstructorDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.constructorKeyword, callSignature, this.block, this.semicolonToken); }; ConstructorDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.constructorKeyword, this.parameterList, block, this.semicolonToken); + return this.update(this.modifiers, this.constructorKeyword, this.callSignature, block, this.semicolonToken); }; ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.constructorKeyword, this.parameterList, this.block, semicolonToken); + return this.update(this.modifiers, this.constructorKeyword, this.callSignature, this.block, semicolonToken); }; ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { @@ -17614,7 +17716,7 @@ var TypeScript; }; SyntaxRewriter.prototype.visitConstructorDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.constructorKeyword), this.visitNode(node.parameterList), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + return node.update(this.visitList(node.modifiers), this.visitToken(node.constructorKeyword), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); }; SyntaxRewriter.prototype.visitMemberFunctionDeclaration = function (node) { @@ -18036,14 +18138,12 @@ var TypeScript; (function (TypeScript) { (function (Syntax) { var VariableWidthTokenWithNoTrivia = (function () { - function VariableWidthTokenWithNoTrivia(sourceText, fullStart, kind, textOrWidth) { - this._sourceText = sourceText; - this._fullStart = fullStart; + function VariableWidthTokenWithNoTrivia(fullText, kind) { + this._fullText = fullText; this.tokenKind = kind; - this._textOrWidth = textOrWidth; } VariableWidthTokenWithNoTrivia.prototype.clone = function () { - return new VariableWidthTokenWithNoTrivia(this._sourceText, this._fullStart, this.tokenKind, this._textOrWidth); + return new VariableWidthTokenWithNoTrivia(this._fullText, this.tokenKind); }; VariableWidthTokenWithNoTrivia.prototype.isNode = function () { @@ -18071,29 +18171,17 @@ var TypeScript; }; VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.width(); + return this.fullText().length; }; - VariableWidthTokenWithNoTrivia.prototype.start = function () { - return this._fullStart; - }; - VariableWidthTokenWithNoTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - VariableWidthTokenWithNoTrivia.prototype.width = function () { - return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); }; VariableWidthTokenWithNoTrivia.prototype.text = function () { - if (typeof this._textOrWidth === 'number') { - this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); - } - - return this._textOrWidth; + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); }; - VariableWidthTokenWithNoTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + return this._fullText; }; VariableWidthTokenWithNoTrivia.prototype.value = function () { @@ -18214,15 +18302,13 @@ var TypeScript; Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; var VariableWidthTokenWithLeadingTrivia = (function () { - function VariableWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, textOrWidth) { - this._sourceText = sourceText; - this._fullStart = fullStart; + function VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { + this._fullText = fullText; this.tokenKind = kind; this._leadingTriviaInfo = leadingTriviaInfo; - this._textOrWidth = textOrWidth; } VariableWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithLeadingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._textOrWidth); + return new VariableWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); }; VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { @@ -18250,29 +18336,17 @@ var TypeScript; }; VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width(); + return this.fullText().length; }; - VariableWidthTokenWithLeadingTrivia.prototype.start = function () { - return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - VariableWidthTokenWithLeadingTrivia.prototype.width = function () { - return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); }; VariableWidthTokenWithLeadingTrivia.prototype.text = function () { - if (typeof this._textOrWidth === 'number') { - this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); - } - - return this._textOrWidth; + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); }; - VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + return this._fullText; }; VariableWidthTokenWithLeadingTrivia.prototype.value = function () { @@ -18307,7 +18381,7 @@ var TypeScript; return getTriviaWidth(this._leadingTriviaInfo); }; VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); }; VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { @@ -18393,15 +18467,13 @@ var TypeScript; Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; var VariableWidthTokenWithTrailingTrivia = (function () { - function VariableWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, textOrWidth, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; + function VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { + this._fullText = fullText; this.tokenKind = kind; - this._textOrWidth = textOrWidth; this._trailingTriviaInfo = trailingTriviaInfo; } VariableWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._textOrWidth, this._trailingTriviaInfo); + return new VariableWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); }; VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { @@ -18429,29 +18501,17 @@ var TypeScript; }; VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.width() + getTriviaWidth(this._trailingTriviaInfo); + return this.fullText().length; }; - VariableWidthTokenWithTrailingTrivia.prototype.start = function () { - return this._fullStart; - }; - VariableWidthTokenWithTrailingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - VariableWidthTokenWithTrailingTrivia.prototype.width = function () { - return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); }; VariableWidthTokenWithTrailingTrivia.prototype.text = function () { - if (typeof this._textOrWidth === 'number') { - this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); - } - - return this._textOrWidth; + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); }; - VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + return this._fullText; }; VariableWidthTokenWithTrailingTrivia.prototype.value = function () { @@ -18505,7 +18565,7 @@ var TypeScript; return getTriviaWidth(this._trailingTriviaInfo); }; VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); }; VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { @@ -18572,16 +18632,14 @@ var TypeScript; Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { - function VariableWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, textOrWidth, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; + function VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo) { + this._fullText = fullText; this.tokenKind = kind; this._leadingTriviaInfo = leadingTriviaInfo; - this._textOrWidth = textOrWidth; this._trailingTriviaInfo = trailingTriviaInfo; } VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._textOrWidth, this._trailingTriviaInfo); + return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); }; VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { @@ -18609,29 +18667,17 @@ var TypeScript; }; VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width() + getTriviaWidth(this._trailingTriviaInfo); + return this.fullText().length; }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.start = function () { - return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { - return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); }; VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { - if (typeof this._textOrWidth === 'number') { - this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); - } - - return this._textOrWidth; + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + return this._fullText; }; VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { @@ -18666,7 +18712,7 @@ var TypeScript; return getTriviaWidth(this._leadingTriviaInfo); }; VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); }; VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { @@ -18685,7 +18731,7 @@ var TypeScript; return getTriviaWidth(this._trailingTriviaInfo); }; VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); }; VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { @@ -18784,11 +18830,12 @@ var TypeScript; }; FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.width(); + return this.fullText().length; }; FixedWidthTokenWithNoTrivia.prototype.width = function () { return this.text().length; }; + FixedWidthTokenWithNoTrivia.prototype.text = function () { return TypeScript.SyntaxFacts.getText(this.tokenKind); }; @@ -18904,14 +18951,13 @@ var TypeScript; Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; var FixedWidthTokenWithLeadingTrivia = (function () { - function FixedWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; + function FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { + this._fullText = fullText; this.tokenKind = kind; this._leadingTriviaInfo = leadingTriviaInfo; } FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithLeadingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo); + return new FixedWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); }; FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { @@ -18939,23 +18985,17 @@ var TypeScript; }; FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width(); + return this.fullText().length; }; - FixedWidthTokenWithLeadingTrivia.prototype.start = function () { - return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - FixedWidthTokenWithLeadingTrivia.prototype.width = function () { return this.text().length; }; + FixedWidthTokenWithLeadingTrivia.prototype.text = function () { return TypeScript.SyntaxFacts.getText(this.tokenKind); }; FixedWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + return this._fullText; }; FixedWidthTokenWithLeadingTrivia.prototype.value = function () { @@ -18980,7 +19020,7 @@ var TypeScript; return getTriviaWidth(this._leadingTriviaInfo); }; FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); }; FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { @@ -19066,14 +19106,13 @@ var TypeScript; Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; var FixedWidthTokenWithTrailingTrivia = (function () { - function FixedWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; + function FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { + this._fullText = fullText; this.tokenKind = kind; this._trailingTriviaInfo = trailingTriviaInfo; } FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._trailingTriviaInfo); + return new FixedWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); }; FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { @@ -19101,23 +19140,17 @@ var TypeScript; }; FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.width() + getTriviaWidth(this._trailingTriviaInfo); + return this.fullText().length; }; - FixedWidthTokenWithTrailingTrivia.prototype.start = function () { - return this._fullStart; - }; - FixedWidthTokenWithTrailingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - FixedWidthTokenWithTrailingTrivia.prototype.width = function () { return this.text().length; }; + FixedWidthTokenWithTrailingTrivia.prototype.text = function () { return TypeScript.SyntaxFacts.getText(this.tokenKind); }; FixedWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + return this._fullText; }; FixedWidthTokenWithTrailingTrivia.prototype.value = function () { @@ -19161,7 +19194,7 @@ var TypeScript; return getTriviaWidth(this._trailingTriviaInfo); }; FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); }; FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { @@ -19228,15 +19261,14 @@ var TypeScript; Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { - function FixedWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; + function FixedWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo) { + this._fullText = fullText; this.tokenKind = kind; this._leadingTriviaInfo = leadingTriviaInfo; this._trailingTriviaInfo = trailingTriviaInfo; } FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithLeadingAndTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); + return new FixedWidthTokenWithLeadingAndTrailingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); }; FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { @@ -19264,23 +19296,17 @@ var TypeScript; }; FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width() + getTriviaWidth(this._trailingTriviaInfo); + return this.fullText().length; }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.start = function () { - return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { return this.text().length; }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { return TypeScript.SyntaxFacts.getText(this.tokenKind); }; FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + return this._fullText; }; FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { @@ -19305,7 +19331,7 @@ var TypeScript; return getTriviaWidth(this._leadingTriviaInfo); }; FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); }; FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { @@ -19324,7 +19350,7 @@ var TypeScript; return getTriviaWidth(this._trailingTriviaInfo); }; FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); }; FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { @@ -19396,36 +19422,6 @@ var TypeScript; token.trailingTrivia().collectTextElements(elements); } - function fixedWidthToken(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo) { - if (leadingTriviaInfo === 0) { - if (trailingTriviaInfo === 0) { - return new FixedWidthTokenWithNoTrivia(kind); - } else { - return new FixedWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new FixedWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo); - } else { - return new FixedWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo); - } - } - Syntax.fixedWidthToken = fixedWidthToken; - - function variableWidthToken(sourceText, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo) { - if (leadingTriviaInfo === 0) { - if (trailingTriviaInfo === 0) { - return new VariableWidthTokenWithNoTrivia(sourceText, fullStart, kind, width); - } else { - return new VariableWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, width, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new VariableWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, width); - } else { - return new VariableWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo); - } - } - Syntax.variableWidthToken = variableWidthToken; - function getTriviaWidth(value) { return value >>> 2 /* TriviaFullWidthShift */; } @@ -19615,7 +19611,7 @@ var TypeScript; case 13 /* carriageReturn */: var nextIndex = i + 1; - if (nextIndex < text.length && text.charCodeAt(nextIndex) == 10 /* lineFeed */) { + if (nextIndex < text.length && text.charCodeAt(nextIndex) === 10 /* lineFeed */) { i++; } continue; @@ -21363,7 +21359,7 @@ var TypeScript; SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { this.visitList(node.modifiers); this.visitToken(node.constructorKeyword); - this.visitNode(node.parameterList); + this.visitNode(node.callSignature); this.visitOptionalNode(node.block); this.visitOptionalToken(node.semicolonToken); }; @@ -21831,7 +21827,7 @@ var TypeScript; ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; - ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeArgumentList_Types] = "LastListParsingState"; + ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeParameterList_TypeParameters] = "LastListParsingState"; })(ListParsingState || (ListParsingState = {})); var SyntaxCursor = (function () { @@ -23200,13 +23196,13 @@ var TypeScript; ParserImpl.prototype.isConstructorDeclaration = function () { var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 62 /* ConstructorKeyword */ && this.peekToken(index + 1).tokenKind === 72 /* OpenParenToken */; + return this.peekToken(index).tokenKind === 62 /* ConstructorKeyword */; }; ParserImpl.prototype.parseConstructorDeclaration = function () { var modifiers = this.parseModifiers(); var constructorKeyword = this.eatKeyword(62 /* ConstructorKeyword */); - var parameterList = this.parseParameterList(); + var callSignature = this.parseCallSignature(false); var semicolonToken = null; var block = null; @@ -23217,7 +23213,7 @@ var TypeScript; semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); } - return this.factory.constructorDeclaration(modifiers, constructorKeyword, parameterList, block, semicolonToken); + return this.factory.constructorDeclaration(modifiers, constructorKeyword, callSignature, block, semicolonToken); }; ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { @@ -25091,10 +25087,6 @@ var TypeScript; var currentToken = this.currentToken(); var currentTokenKind = currentToken.tokenKind; - if (currentTokenKind === 39 /* TypeOfKeyword */) { - return this.parseTypeQuery(); - } - var type = this.parseNonArrayType(currentToken); while (this.currentToken().tokenKind === 74 /* OpenBracketToken */) { @@ -25137,6 +25129,9 @@ var TypeScript; case 31 /* NewKeyword */: return this.parseConstructorType(); + + case 39 /* TypeOfKeyword */: + return this.parseTypeQuery(); } return this.parseNameOrGenericType(); @@ -25262,7 +25257,7 @@ var TypeScript; ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { this.reportUnexpectedTokenDiagnostic(currentListType); - for (var state = 262144 /* LastListParsingState */; state >= 1 /* FirstListParsingState */; state >>= 1) { + for (var state = 524288 /* LastListParsingState */; state >= 1 /* FirstListParsingState */; state >>= 1) { if ((this.listParsingState & state) !== 0) { if (this.isExpectedListTerminator(state) || this.isExpectedListItem(state, true)) { return true; @@ -26098,14 +26093,11 @@ var TypeScript; return true; } - if (this.inAmbientDeclaration) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Parameter_property_declarations_cannot_be_used_in_an_ambient_context); - return true; - } else if (this.currentConstructor && !this.currentConstructor.block && this.currentConstructor.parameterList === parameterList) { + if (!this.inAmbientDeclaration && this.currentConstructor && !this.currentConstructor.block && this.currentConstructor.callSignature.parameterList === parameterList) { this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Parameter_property_declarations_cannot_be_used_in_a_constructor_overload); return true; - } else if (this.currentConstructor === null || this.currentConstructor.parameterList !== parameterList) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Parameter_property_declarations_can_only_be_used_in_constructors); + } else if (this.inAmbientDeclaration || this.currentConstructor === null || this.currentConstructor.callSignature.parameterList !== parameterList) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Parameter_property_declarations_can_only_be_used_in_a_non_ambient_constructor_declaration); return true; } } @@ -26337,9 +26329,22 @@ var TypeScript; inFunctionOverloadChain = functionDeclaration.block === null; functionOverloadChainName = functionDeclaration.identifier.valueText(); - if (lastElement && inFunctionOverloadChain) { - this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; + if (inFunctionOverloadChain) { + if (lastElement) { + this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } else { + var nextElement = moduleElements.childAt(i + 1); + if (nextElement.kind() === 129 /* FunctionDeclaration */) { + var nextFunction = nextElement; + + if (nextFunction.identifier.valueText() !== functionOverloadChainName && nextFunction.block === null) { + var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); + this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + } + } } } else { inFunctionOverloadChain = false; @@ -26382,9 +26387,10 @@ var TypeScript; this.pushDiagnostic1(propertyNameFullStart, memberFunctionDeclaration.propertyName, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); return true; } + isStaticOverload = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); if (isStaticOverload !== isInStaticOverloadChain) { - propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); + var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); var diagnostic = isInStaticOverloadChain ? TypeScript.DiagnosticCode.Function_overload_must_be_static : TypeScript.DiagnosticCode.Function_overload_must_not_be_static; this.pushDiagnostic1(propertyNameFullStart, memberFunctionDeclaration.propertyName, diagnostic, null); return true; @@ -26403,9 +26409,22 @@ var TypeScript; functionOverloadChainName = memberFunctionDeclaration.propertyName.valueText(); isInStaticOverloadChain = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); - if (lastElement && inFunctionOverloadChain) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; + if (inFunctionOverloadChain) { + if (lastElement) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } else { + var nextElement = node.classElements.childAt(i + 1); + if (nextElement.kind() === 135 /* MemberFunctionDeclaration */) { + var nextMemberFunction = nextElement; + + if (nextMemberFunction.propertyName.valueText() !== functionOverloadChainName && nextMemberFunction.block === null) { + var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); + this.pushDiagnostic1(propertyNameFullStart, memberFunctionDeclaration.propertyName, TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + } + } } } else if (classElement.kind() === 137 /* ConstructorDeclaration */) { var constructorDeclaration = classElement; @@ -26696,23 +26715,21 @@ var TypeScript; GrammarCheckerWalker.prototype.checkEnumElements = function (node) { var enumElementFullStart = this.childFullStart(node, node.enumElements); - var seenComputedValue = false; + var previousValueWasComputed = false; for (var i = 0, n = node.enumElements.childCount(); i < n; i++) { var child = node.enumElements.childAt(i); if (i % 2 === 0) { var enumElement = child; - if (!enumElement.equalsValueClause && seenComputedValue) { + if (!enumElement.equalsValueClause && previousValueWasComputed) { this.pushDiagnostic1(enumElementFullStart, enumElement, TypeScript.DiagnosticCode.Enum_member_must_have_initializer, null); return true; } if (enumElement.equalsValueClause) { var value = enumElement.equalsValueClause.value; - if (!TypeScript.Syntax.isIntegerLiteral(value)) { - seenComputedValue = true; - } + previousValueWasComputed = !TypeScript.Syntax.isIntegerLiteral(value); } } @@ -26999,7 +27016,7 @@ var TypeScript; }; GrammarCheckerWalker.prototype.visitForInStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { + if (this.checkForStatementInAmbientContxt(node) || this.checkForInStatementVariableDeclaration(node)) { this.skip(node); return; } @@ -27007,6 +27024,17 @@ var TypeScript; _super.prototype.visitForInStatement.call(this, node); }; + GrammarCheckerWalker.prototype.checkForInStatementVariableDeclaration = function (node) { + if (node.variableDeclaration && node.variableDeclaration.variableDeclarators.nonSeparatorCount() > 1) { + var variableDeclarationFullStart = this.childFullStart(node, node.variableDeclaration); + + this.pushDiagnostic1(variableDeclarationFullStart, node.variableDeclaration, TypeScript.DiagnosticCode.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement); + return true; + } + + return false; + }; + GrammarCheckerWalker.prototype.visitForStatement = function (node) { if (this.checkForStatementInAmbientContxt(node)) { this.skip(node); @@ -27183,7 +27211,7 @@ var TypeScript; }; GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers) || this.checkConstructorModifiers(node.modifiers)) { + if (this.checkClassElementModifiers(node.modifiers) || this.checkConstructorModifiers(node.modifiers) || this.checkConstructorTypeParameterList(node) || this.checkConstructorTypeAnnotation(node)) { this.skip(node); return; } @@ -27210,6 +27238,32 @@ var TypeScript; return false; }; + GrammarCheckerWalker.prototype.checkConstructorTypeParameterList = function (node) { + var currentElementFullStart = this.position(); + + if (node.callSignature.typeParameterList) { + var callSignatureFullStart = this.childFullStart(node, node.callSignature); + var typeParameterListFullStart = callSignatureFullStart + TypeScript.Syntax.childOffset(node.callSignature, node.callSignature.typeAnnotation); + this.pushDiagnostic1(callSignatureFullStart, node.callSignature.typeParameterList, TypeScript.DiagnosticCode.Type_parameters_cannot_appear_on_a_constructor_declaration); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkConstructorTypeAnnotation = function (node) { + var currentElementFullStart = this.position(); + + if (node.callSignature.typeAnnotation) { + var callSignatureFullStart = this.childFullStart(node, node.callSignature); + var typeAnnotationFullStart = callSignatureFullStart + TypeScript.Syntax.childOffset(node.callSignature, node.callSignature.typeAnnotation); + this.pushDiagnostic1(typeAnnotationFullStart, node.callSignature.typeAnnotation, TypeScript.DiagnosticCode.Type_annotation_cannot_appear_on_a_constructor_declaration); + return true; + } + + return false; + }; + GrammarCheckerWalker.prototype.visitSourceUnit = function (node) { if (this.checkFunctionOverloads(node, node.moduleElements) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { this.skip(node); @@ -27343,7 +27397,9 @@ var TypeScript; var start = (new Date()).getTime(); var result = func(); var end = (new Date()).getTime(); - logger.log(funcDescription + " completed in " + (end - start) + " msec"); + if (logger.information()) { + logger.log(funcDescription + " completed in " + (end - start) + " msec"); + } return result; } TypeScript.timeFunction = timeFunction; @@ -27368,8 +27424,8 @@ var TypeScript; this._lineMap = null; this._declASTMap = []; this._astDeclMap = []; - this._isExternalModule = undefined; this._amdDependencies = undefined; + this._externalModuleIndicatorSpan = undefined; } Document.prototype.invalidate = function () { this._declASTMap.length = 0; @@ -27394,39 +27450,22 @@ var TypeScript; this._lineMap = syntaxTree.lineMap(); var sourceUnit = syntaxTree.sourceUnit(); - var leadingComments = this.getLeadingComments(sourceUnit); + var leadingTrivia = sourceUnit.leadingTrivia(); - this._isExternalModule = this.hasImplicitImport(leadingComments) || this.hasTopLevelImportOrExport(sourceUnit); + this._externalModuleIndicatorSpan = this.getImplicitImportSpan(leadingTrivia) || this.getTopLevelImportOrExportSpan(sourceUnit); var amdDependencies = []; - for (var i = 0, n = leadingComments.length; i < n; i++) { - var trivia = leadingComments[i]; - var amdDependency = this.getAmdDependency(trivia.fullText()); - if (amdDependency) { - amdDependencies.push(amdDependency); - } - } - - this._amdDependencies = amdDependencies; - }; - - Document.prototype.getLeadingComments = function (node) { - var firstToken = node.firstToken(); - var result = []; - - if (firstToken.hasLeadingComment()) { - var leadingTrivia = firstToken.leadingTrivia(); - - for (var i = 0, n = leadingTrivia.count(); i < n; i++) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - - if (trivia.isComment()) { - result.push(trivia); + for (var i = 0, n = leadingTrivia.count(); i < n; i++) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + if (trivia.isComment()) { + var amdDependency = this.getAmdDependency(trivia.fullText()); + if (amdDependency) { + amdDependencies.push(amdDependency); } } } - return result; + this._amdDependencies = amdDependencies; }; Document.prototype.getAmdDependency = function (comment) { @@ -27435,49 +27474,60 @@ var TypeScript; return match ? match[2] : null; }; - Document.prototype.hasImplicitImport = function (sourceUnitLeadingComments) { - for (var i = 0, n = sourceUnitLeadingComments.length; i < n; i++) { - var trivia = sourceUnitLeadingComments[i]; + Document.prototype.getImplicitImportSpan = function (sourceUnitLeadingTrivia) { + var position = 0; - if (this.getImplicitImport(trivia.fullText())) { - return true; + for (var i = 0, n = sourceUnitLeadingTrivia.count(); i < n; i++) { + var trivia = sourceUnitLeadingTrivia.syntaxTriviaAt(i); + + if (trivia.isComment()) { + var span = this.getImplicitImportSpanWorker(trivia, position); + if (span) { + return span; + } } + + position += trivia.fullWidth(); } - return false; + return null; }; - Document.prototype.getImplicitImport = function (comment) { + Document.prototype.getImplicitImportSpanWorker = function (trivia, position) { var implicitImportRegEx = /^(\/\/\/\s*/gim; - var match = implicitImportRegEx.exec(comment); + var match = implicitImportRegEx.exec(trivia.fullText()); if (match) { - return true; + return new TypeScript.TextSpan(position, trivia.fullWidth()); } - return false; + return null; }; - Document.prototype.hasTopLevelImportOrExport = function (node) { + Document.prototype.getTopLevelImportOrExportSpan = function (node) { var firstToken; + var position = 0; for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { var moduleElement = node.moduleElements.childAt(i); firstToken = moduleElement.firstToken(); if (firstToken !== null && firstToken.tokenKind === 47 /* ExportKeyword */) { - return true; + return new TypeScript.TextSpan(position + firstToken.leadingTriviaWidth(), firstToken.width()); } if (moduleElement.kind() === 133 /* ImportDeclaration */) { var importDecl = moduleElement; if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { - return true; + return new TypeScript.TextSpan(position + importDecl.leadingTriviaWidth(), importDecl.width()); } } + + position += moduleElement.fullWidth(); } - return false; + return null; + ; }; Document.prototype.sourceUnit = function () { @@ -27514,12 +27564,16 @@ var TypeScript; }; Document.prototype.isExternalModule = function () { - if (this._isExternalModule === undefined) { + return this.externalModuleIndicatorSpan() !== null; + }; + + Document.prototype.externalModuleIndicatorSpan = function () { + if (this._externalModuleIndicatorSpan === undefined) { this.syntaxTree(); - TypeScript.Debug.assert(this._isExternalModule !== undefined); + TypeScript.Debug.assert(this._externalModuleIndicatorSpan !== undefined); } - return this._isExternalModule; + return this._externalModuleIndicatorSpan; }; Document.prototype.amdDependencies = function () { @@ -27553,7 +27607,7 @@ var TypeScript; if (!this._bloomFilter) { var identifiers = TypeScript.createIntrinsicsObject(); var pre = function (cur) { - if (TypeScript.isValidAstNode(cur)) { + if (TypeScript.ASTHelpers.isValidAstNode(cur)) { if (cur.kind() === 11 /* IdentifierName */) { var nodeText = cur.valueText(); @@ -27859,246 +27913,261 @@ var TypeScript; })(StringHashTable); TypeScript.IdentiferNameHashTable = IdentiferNameHashTable; })(TypeScript || (TypeScript = {})); + var TypeScript; (function (TypeScript) { - function scriptIsElided(sourceUnit) { - return TypeScript.isDTSFile(sourceUnit.fileName()) || moduleMembersAreElided(sourceUnit.moduleElements); - } - TypeScript.scriptIsElided = scriptIsElided; + (function (ASTHelpers) { + function scriptIsElided(sourceUnit) { + return TypeScript.isDTSFile(sourceUnit.fileName()) || moduleMembersAreElided(sourceUnit.moduleElements); + } + ASTHelpers.scriptIsElided = scriptIsElided; - function moduleIsElided(declaration) { - return TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) || moduleMembersAreElided(declaration.moduleElements); - } - TypeScript.moduleIsElided = moduleIsElided; + function moduleIsElided(declaration) { + return TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) || moduleMembersAreElided(declaration.moduleElements); + } + ASTHelpers.moduleIsElided = moduleIsElided; - function moduleMembersAreElided(members) { - for (var i = 0, n = members.childCount(); i < n; i++) { - var member = members.childAt(i); + function moduleMembersAreElided(members) { + for (var i = 0, n = members.childCount(); i < n; i++) { + var member = members.childAt(i); - if (member.kind() === 130 /* ModuleDeclaration */) { - if (!moduleIsElided(member)) { + if (member.kind() === 130 /* ModuleDeclaration */) { + if (!moduleIsElided(member)) { + return false; + } + } else if (member.kind() !== 128 /* InterfaceDeclaration */) { return false; } - } else if (member.kind() !== 128 /* InterfaceDeclaration */) { - return false; } - } - return true; - } - - function enumIsElided(declaration) { - if (TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */)) { return true; } - return false; - } - TypeScript.enumIsElided = enumIsElided; - - function importDeclarationIsElided(importDeclAST, semanticInfoChain, compilationSettings) { - if (typeof compilationSettings === "undefined") { compilationSettings = null; } - var isExternalModuleReference = importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */; - var importDecl = semanticInfoChain.getDeclForAST(importDeclAST); - var isExported = TypeScript.hasFlag(importDecl.flags, 1 /* Exported */); - var isAmdCodeGen = compilationSettings && compilationSettings.moduleGenTarget() == 2 /* Asynchronous */; - - if (!isExternalModuleReference || isExported || !isAmdCodeGen) { - var importSymbol = importDecl.getSymbol(); - if (importDeclAST.moduleReference.kind() !== 245 /* ExternalModuleReference */) { - if (importSymbol.getExportAssignedValueSymbol()) { - return true; - } - var containerSymbol = importSymbol.getExportAssignedContainerSymbol(); - if (containerSymbol && containerSymbol.getInstanceSymbol()) { - return true; - } + function enumIsElided(declaration) { + if (TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */)) { + return true; } - return importSymbol.isUsedAsValue(); + return false; } + ASTHelpers.enumIsElided = enumIsElided; - return false; - } - TypeScript.importDeclarationIsElided = importDeclarationIsElided; + function isValidAstNode(ast) { + if (!ast) + return false; - function isValidAstNode(ast) { - if (!ast) - return false; + if (ast.start() === -1 || ast.end() === -1) + return false; - if (ast.start() === -1 || ast.end() === -1) - return false; + return true; + } + ASTHelpers.isValidAstNode = isValidAstNode; - return true; - } - TypeScript.isValidAstNode = isValidAstNode; + function getAstAtPosition(script, pos, useTrailingTriviaAsLimChar, forceInclusive) { + if (typeof useTrailingTriviaAsLimChar === "undefined") { useTrailingTriviaAsLimChar = true; } + if (typeof forceInclusive === "undefined") { forceInclusive = false; } + var top = null; - function getAstAtPosition(script, pos, useTrailingTriviaAsLimChar, forceInclusive) { - if (typeof useTrailingTriviaAsLimChar === "undefined") { useTrailingTriviaAsLimChar = true; } - if (typeof forceInclusive === "undefined") { forceInclusive = false; } - var top = null; + var pre = function (cur, walker) { + if (isValidAstNode(cur)) { + var isInvalid1 = cur.kind() === 149 /* ExpressionStatement */ && cur.width() === 0; - var pre = function (cur, walker) { - if (isValidAstNode(cur)) { - var isInvalid1 = cur.kind() === 149 /* ExpressionStatement */ && cur.width() === 0; + if (isInvalid1) { + walker.options.goChildren = false; + } else { + var inclusive = forceInclusive || cur.kind() === 11 /* IdentifierName */ || cur.kind() === 212 /* MemberAccessExpression */ || cur.kind() === 121 /* QualifiedName */ || cur.kind() === 224 /* VariableDeclaration */ || cur.kind() === 225 /* VariableDeclarator */ || cur.kind() === 213 /* InvocationExpression */ || pos === script.end() + script.trailingTriviaWidth(); - if (isInvalid1) { - walker.options.goChildren = false; - } else { - var inclusive = forceInclusive || cur.kind() === 11 /* IdentifierName */ || cur.kind() === 212 /* MemberAccessExpression */ || cur.kind() === 121 /* QualifiedName */ || cur.kind() === 224 /* VariableDeclaration */ || cur.kind() === 225 /* VariableDeclarator */ || cur.kind() === 213 /* InvocationExpression */ || pos === script.end() + script.trailingTriviaWidth(); - - var minChar = cur.start(); - var limChar = cur.end() + (useTrailingTriviaAsLimChar ? cur.trailingTriviaWidth() : 0) + (inclusive ? 1 : 0); - if (pos >= minChar && pos < limChar) { - if ((cur.kind() !== 1 /* List */ && cur.kind() !== 2 /* SeparatedList */) || cur.end() > cur.start()) { - if (top === null) { - top = cur; - } else if (cur.start() >= top.start() && (cur.end() + (useTrailingTriviaAsLimChar ? cur.trailingTriviaWidth() : 0)) <= (top.end() + (useTrailingTriviaAsLimChar ? top.trailingTriviaWidth() : 0))) { - if (top.width() !== 0 || cur.width() !== 0) { + var minChar = cur.start(); + var limChar = cur.end() + (useTrailingTriviaAsLimChar ? cur.trailingTriviaWidth() : 0) + (inclusive ? 1 : 0); + if (pos >= minChar && pos < limChar) { + if ((cur.kind() !== 1 /* List */ && cur.kind() !== 2 /* SeparatedList */) || cur.end() > cur.start()) { + if (top === null) { top = cur; + } else if (cur.start() >= top.start() && (cur.end() + (useTrailingTriviaAsLimChar ? cur.trailingTriviaWidth() : 0)) <= (top.end() + (useTrailingTriviaAsLimChar ? top.trailingTriviaWidth() : 0))) { + if (top.width() !== 0 || cur.width() !== 0) { + top = cur; + } } } } - } - walker.options.goChildren = (minChar <= pos && pos <= limChar); + walker.options.goChildren = (minChar <= pos && pos <= limChar); + } + } + }; + + TypeScript.getAstWalkerFactory().walk(script, pre); + return top; + } + ASTHelpers.getAstAtPosition = getAstAtPosition; + + function getExtendsHeritageClause(clauses) { + if (!clauses) { + return null; + } + + return clauses.firstOrDefault(function (c) { + return c.typeNames.nonSeparatorCount() > 0 && c.kind() === 230 /* ExtendsHeritageClause */; + }); + } + ASTHelpers.getExtendsHeritageClause = getExtendsHeritageClause; + + function getImplementsHeritageClause(clauses) { + if (!clauses) { + return null; + } + + return clauses.firstOrDefault(function (c) { + return c.typeNames.nonSeparatorCount() > 0 && c.kind() === 231 /* ImplementsHeritageClause */; + }); + } + ASTHelpers.getImplementsHeritageClause = getImplementsHeritageClause; + + function isCallExpression(ast) { + return (ast && ast.kind() === 213 /* InvocationExpression */) || (ast && ast.kind() === 216 /* ObjectCreationExpression */); + } + ASTHelpers.isCallExpression = isCallExpression; + + function isCallExpressionTarget(ast) { + if (!ast) { + return false; + } + + var current = ast; + + while (current && current.parent) { + if (current.parent.kind() === 212 /* MemberAccessExpression */ && current.parent.name === current) { + current = current.parent; + continue; + } + + break; + } + + if (current && current.parent) { + if (current.parent.kind() === 213 /* InvocationExpression */ || current.parent.kind() === 216 /* ObjectCreationExpression */) { + return current === current.parent.expression; } } - }; - TypeScript.getAstWalkerFactory().walk(script, pre); - return top; - } - TypeScript.getAstAtPosition = getAstAtPosition; - - function getExtendsHeritageClause(clauses) { - if (!clauses) { - return null; + return false; } + ASTHelpers.isCallExpressionTarget = isCallExpressionTarget; - return clauses.firstOrDefault(function (c) { - return c.typeNames.nonSeparatorCount() > 0 && c.kind() === 230 /* ExtendsHeritageClause */; - }); - } - TypeScript.getExtendsHeritageClause = getExtendsHeritageClause; + function isNameOfSomeDeclaration(ast) { + if (ast === null || ast.parent === null) { + return false; + } + if (ast.kind() !== 11 /* IdentifierName */) { + return false; + } - function getImplementsHeritageClause(clauses) { - if (!clauses) { - return null; - } + switch (ast.parent.kind()) { + case 131 /* ClassDeclaration */: + return ast.parent.identifier === ast; + case 128 /* InterfaceDeclaration */: + return ast.parent.identifier === ast; + case 132 /* EnumDeclaration */: + return ast.parent.identifier === ast; + case 130 /* ModuleDeclaration */: + return ast.parent.name === ast || ast.parent.stringLiteral === ast; + case 225 /* VariableDeclarator */: + return ast.parent.propertyName === ast; + case 129 /* FunctionDeclaration */: + return ast.parent.identifier === ast; + case 135 /* MemberFunctionDeclaration */: + return ast.parent.propertyName === ast; + case 242 /* Parameter */: + return ast.parent.identifier === ast; + case 238 /* TypeParameter */: + return ast.parent.identifier === ast; + case 240 /* SimplePropertyAssignment */: + return ast.parent.propertyName === ast; + case 241 /* FunctionPropertyAssignment */: + return ast.parent.propertyName === ast; + case 243 /* EnumElement */: + return ast.parent.propertyName === ast; + case 133 /* ImportDeclaration */: + return ast.parent.identifier === ast; + } - return clauses.firstOrDefault(function (c) { - return c.typeNames.nonSeparatorCount() > 0 && c.kind() === 231 /* ImplementsHeritageClause */; - }); - } - TypeScript.getImplementsHeritageClause = getImplementsHeritageClause; - - function isCallExpression(ast) { - return (ast && ast.kind() === 213 /* InvocationExpression */) || (ast && ast.kind() === 216 /* ObjectCreationExpression */); - } - TypeScript.isCallExpression = isCallExpression; - - function isCallExpressionTarget(ast) { - if (!ast) { return false; } - var current = ast; + function isDeclarationASTOrDeclarationNameAST(ast) { + return isNameOfSomeDeclaration(ast) || isDeclarationAST(ast); + } + ASTHelpers.isDeclarationASTOrDeclarationNameAST = isDeclarationASTOrDeclarationNameAST; + + function getEnclosingParameterForInitializer(ast) { + var current = ast; + while (current) { + switch (current.kind()) { + case 232 /* EqualsValueClause */: + if (current.parent && current.parent.kind() === 242 /* Parameter */) { + return current.parent; + } + break; + case 131 /* ClassDeclaration */: + case 128 /* InterfaceDeclaration */: + case 130 /* ModuleDeclaration */: + return null; + } - while (current && current.parent) { - if (current.parent.kind() === 212 /* MemberAccessExpression */ && current.parent.name === current) { current = current.parent; - continue; + } + return null; + } + ASTHelpers.getEnclosingParameterForInitializer = getEnclosingParameterForInitializer; + + function getEnclosingMemberVariableDeclaration(ast) { + var current = ast; + + while (current) { + switch (current.kind()) { + case 136 /* MemberVariableDeclaration */: + return current; + case 131 /* ClassDeclaration */: + case 128 /* InterfaceDeclaration */: + case 130 /* ModuleDeclaration */: + return null; + } + current = current.parent; } - break; + return null; } + ASTHelpers.getEnclosingMemberVariableDeclaration = getEnclosingMemberVariableDeclaration; - if (current && current.parent) { - if (current.parent.kind() === 213 /* InvocationExpression */ || current.parent.kind() === 216 /* ObjectCreationExpression */) { - return current === current.parent.expression; + function isNameOfFunction(ast) { + return ast && ast.parent && ast.kind() === 11 /* IdentifierName */ && ast.parent.kind() === 129 /* FunctionDeclaration */ && ast.parent.identifier === ast; + } + ASTHelpers.isNameOfFunction = isNameOfFunction; + + function isNameOfMemberFunction(ast) { + return ast && ast.parent && ast.kind() === 11 /* IdentifierName */ && ast.parent.kind() === 135 /* MemberFunctionDeclaration */ && ast.parent.propertyName === ast; + } + ASTHelpers.isNameOfMemberFunction = isNameOfMemberFunction; + + function isNameOfMemberAccessExpression(ast) { + if (ast && ast.parent && ast.parent.kind() === 212 /* MemberAccessExpression */ && ast.parent.name === ast) { + return true; } - } - return false; - } - TypeScript.isCallExpressionTarget = isCallExpressionTarget; - - function isNameOfSomeDeclaration(ast) { - if (ast === null || ast.parent === null) { return false; } - if (ast.kind() !== 11 /* IdentifierName */) { + ASTHelpers.isNameOfMemberAccessExpression = isNameOfMemberAccessExpression; + + function isRightSideOfQualifiedName(ast) { + if (ast && ast.parent && ast.parent.kind() === 121 /* QualifiedName */ && ast.parent.right === ast) { + return true; + } + return false; } + ASTHelpers.isRightSideOfQualifiedName = isRightSideOfQualifiedName; - switch (ast.parent.kind()) { - case 131 /* ClassDeclaration */: - return ast.parent.identifier === ast; - case 128 /* InterfaceDeclaration */: - return ast.parent.identifier === ast; - case 132 /* EnumDeclaration */: - return ast.parent.identifier === ast; - case 130 /* ModuleDeclaration */: - return ast.parent.name === ast || ast.parent.stringLiteral === ast; - case 225 /* VariableDeclarator */: - return ast.parent.propertyName === ast; - case 129 /* FunctionDeclaration */: - return ast.parent.identifier === ast; - case 135 /* MemberFunctionDeclaration */: - return ast.parent.propertyName === ast; - case 242 /* Parameter */: - return ast.parent.identifier === ast; - case 238 /* TypeParameter */: - return ast.parent.identifier === ast; - case 240 /* SimplePropertyAssignment */: - return ast.parent.propertyName === ast; - case 241 /* FunctionPropertyAssignment */: - return ast.parent.propertyName === ast; - case 243 /* EnumElement */: - return ast.parent.propertyName === ast; - case 133 /* ImportDeclaration */: - return ast.parent.identifier === ast; - } - - return false; - } - - function isDeclarationASTOrDeclarationNameAST(ast) { - return isNameOfSomeDeclaration(ast) || isDeclarationAST(ast); - } - TypeScript.isDeclarationASTOrDeclarationNameAST = isDeclarationASTOrDeclarationNameAST; - - function isNameOfFunction(ast) { - return ast && ast.parent && ast.kind() === 11 /* IdentifierName */ && ast.parent.kind() === 129 /* FunctionDeclaration */ && ast.parent.identifier === ast; - } - TypeScript.isNameOfFunction = isNameOfFunction; - - function isNameOfMemberFunction(ast) { - return ast && ast.parent && ast.kind() === 11 /* IdentifierName */ && ast.parent.kind() === 135 /* MemberFunctionDeclaration */ && ast.parent.propertyName === ast; - } - TypeScript.isNameOfMemberFunction = isNameOfMemberFunction; - - function isNameOfMemberAccessExpression(ast) { - if (ast && ast.parent && ast.parent.kind() === 212 /* MemberAccessExpression */ && ast.parent.name === ast) { - return true; - } - - return false; - } - TypeScript.isNameOfMemberAccessExpression = isNameOfMemberAccessExpression; - - function isRightSideOfQualifiedName(ast) { - if (ast && ast.parent && ast.parent.kind() === 121 /* QualifiedName */ && ast.parent.right === ast) { - return true; - } - - return false; - } - TypeScript.isRightSideOfQualifiedName = isRightSideOfQualifiedName; - - (function (Parameters) { - function fromIdentifier(id) { + function parametersFromIdentifier(id) { return { length: 1, lastParameterIsRest: function () { @@ -28122,9 +28191,9 @@ var TypeScript; } }; } - Parameters.fromIdentifier = fromIdentifier; + ASTHelpers.parametersFromIdentifier = parametersFromIdentifier; - function fromParameter(parameter) { + function parametersFromParameter(parameter) { return { length: 1, lastParameterIsRest: function () { @@ -28138,7 +28207,7 @@ var TypeScript; return parameter.identifier; }, typeAt: function (index) { - return TypeScript.getType(parameter); + return getType(parameter); }, initializerAt: function (index) { return parameter.equalsValueClause; @@ -28148,13 +28217,13 @@ var TypeScript; } }; } - Parameters.fromParameter = fromParameter; + ASTHelpers.parametersFromParameter = parametersFromParameter; function parameterIsOptional(parameter) { return parameter.questionToken !== null || parameter.equalsValueClause !== null; } - function fromParameterList(list) { + function parametersFromParameterList(list) { return { length: list.parameters.nonSeparatorCount(), lastParameterIsRest: function () { @@ -28168,7 +28237,7 @@ var TypeScript; return list.parameters.nonSeparatorAt(index).identifier; }, typeAt: function (index) { - return TypeScript.getType(list.parameters.nonSeparatorAt(index)); + return getType(list.parameters.nonSeparatorAt(index)); }, initializerAt: function (index) { return list.parameters.nonSeparatorAt(index).equalsValueClause; @@ -28178,240 +28247,251 @@ var TypeScript; } }; } - Parameters.fromParameterList = fromParameterList; - })(TypeScript.Parameters || (TypeScript.Parameters = {})); - var Parameters = TypeScript.Parameters; + ASTHelpers.parametersFromParameterList = parametersFromParameterList; - function isDeclarationAST(ast) { - switch (ast.kind()) { - case 225 /* VariableDeclarator */: - return getVariableStatement(ast) !== null; + function isDeclarationAST(ast) { + switch (ast.kind()) { + case 225 /* VariableDeclarator */: + return getVariableStatement(ast) !== null; - case 133 /* ImportDeclaration */: - case 131 /* ClassDeclaration */: - case 128 /* InterfaceDeclaration */: - case 242 /* Parameter */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 144 /* IndexSignature */: - case 129 /* FunctionDeclaration */: - case 130 /* ModuleDeclaration */: - case 124 /* ArrayType */: - case 122 /* ObjectType */: - case 238 /* TypeParameter */: - case 137 /* ConstructorDeclaration */: - case 135 /* MemberFunctionDeclaration */: - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - case 136 /* MemberVariableDeclaration */: - case 138 /* IndexMemberDeclaration */: - case 132 /* EnumDeclaration */: - case 243 /* EnumElement */: - case 240 /* SimplePropertyAssignment */: - case 241 /* FunctionPropertyAssignment */: - case 222 /* FunctionExpression */: - case 142 /* CallSignature */: - case 143 /* ConstructSignature */: - case 145 /* MethodSignature */: - case 141 /* PropertySignature */: - return true; - default: - return false; + case 133 /* ImportDeclaration */: + case 131 /* ClassDeclaration */: + case 128 /* InterfaceDeclaration */: + case 242 /* Parameter */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 144 /* IndexSignature */: + case 129 /* FunctionDeclaration */: + case 130 /* ModuleDeclaration */: + case 124 /* ArrayType */: + case 122 /* ObjectType */: + case 238 /* TypeParameter */: + case 137 /* ConstructorDeclaration */: + case 135 /* MemberFunctionDeclaration */: + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + case 136 /* MemberVariableDeclaration */: + case 138 /* IndexMemberDeclaration */: + case 132 /* EnumDeclaration */: + case 243 /* EnumElement */: + case 240 /* SimplePropertyAssignment */: + case 241 /* FunctionPropertyAssignment */: + case 222 /* FunctionExpression */: + case 142 /* CallSignature */: + case 143 /* ConstructSignature */: + case 145 /* MethodSignature */: + case 141 /* PropertySignature */: + return true; + default: + return false; + } } - } - TypeScript.isDeclarationAST = isDeclarationAST; + ASTHelpers.isDeclarationAST = isDeclarationAST; - function docComments(ast) { - if (isDeclarationAST(ast)) { - var preComments = ast.kind() === 225 /* VariableDeclarator */ ? getVariableStatement(ast).preComments() : ast.preComments(); + function docComments(ast) { + if (isDeclarationAST(ast)) { + var preComments = ast.kind() === 225 /* VariableDeclarator */ ? getVariableStatement(ast).preComments() : ast.preComments(); - if (preComments && preComments.length > 0) { - var preCommentsLength = preComments.length; - var docComments = new Array(); - for (var i = preCommentsLength - 1; i >= 0; i--) { - if (isDocComment(preComments[i])) { - docComments.push(preComments[i]); - continue; + if (preComments && preComments.length > 0) { + var preCommentsLength = preComments.length; + var docComments = new Array(); + for (var i = preCommentsLength - 1; i >= 0; i--) { + if (isDocComment(preComments[i])) { + docComments.push(preComments[i]); + continue; + } + + break; } - break; + return docComments.reverse(); + } + } + + return TypeScript.sentinelEmptyArray; + } + ASTHelpers.docComments = docComments; + + function isDocComment(comment) { + if (comment.kind() === 6 /* MultiLineCommentTrivia */) { + var fullText = comment.fullText(); + return fullText.charAt(2) === "*" && fullText.charAt(3) !== "/"; + } + + return false; + } + + function getParameterList(ast) { + if (ast) { + switch (ast.kind()) { + case 137 /* ConstructorDeclaration */: + return getParameterList(ast.callSignature); + case 129 /* FunctionDeclaration */: + return getParameterList(ast.callSignature); + case 218 /* ParenthesizedArrowFunctionExpression */: + return getParameterList(ast.callSignature); + case 143 /* ConstructSignature */: + return getParameterList(ast.callSignature); + case 135 /* MemberFunctionDeclaration */: + return getParameterList(ast.callSignature); + case 241 /* FunctionPropertyAssignment */: + return getParameterList(ast.callSignature); + case 222 /* FunctionExpression */: + return getParameterList(ast.callSignature); + case 145 /* MethodSignature */: + return getParameterList(ast.callSignature); + case 125 /* ConstructorType */: + return ast.parameterList; + case 123 /* FunctionType */: + return ast.parameterList; + case 142 /* CallSignature */: + return ast.parameterList; + case 139 /* GetAccessor */: + return ast.parameterList; + case 140 /* SetAccessor */: + return ast.parameterList; + } + } + + return null; + } + ASTHelpers.getParameterList = getParameterList; + + function getType(ast) { + if (ast) { + switch (ast.kind()) { + case 129 /* FunctionDeclaration */: + return getType(ast.callSignature); + case 218 /* ParenthesizedArrowFunctionExpression */: + return getType(ast.callSignature); + case 143 /* ConstructSignature */: + return getType(ast.callSignature); + case 135 /* MemberFunctionDeclaration */: + return getType(ast.callSignature); + case 241 /* FunctionPropertyAssignment */: + return getType(ast.callSignature); + case 222 /* FunctionExpression */: + return getType(ast.callSignature); + case 145 /* MethodSignature */: + return getType(ast.callSignature); + case 142 /* CallSignature */: + return getType(ast.typeAnnotation); + case 144 /* IndexSignature */: + return getType(ast.typeAnnotation); + case 141 /* PropertySignature */: + return getType(ast.typeAnnotation); + case 139 /* GetAccessor */: + return getType(ast.typeAnnotation); + case 242 /* Parameter */: + return getType(ast.typeAnnotation); + case 136 /* MemberVariableDeclaration */: + return getType(ast.variableDeclarator); + case 225 /* VariableDeclarator */: + return getType(ast.typeAnnotation); + case 236 /* CatchClause */: + return getType(ast.typeAnnotation); + case 125 /* ConstructorType */: + return ast.type; + case 123 /* FunctionType */: + return ast.type; + case 244 /* TypeAnnotation */: + return ast.type; + } + } + + return null; + } + ASTHelpers.getType = getType; + + function getVariableStatement(variableDeclarator) { + if (variableDeclarator && variableDeclarator.parent && variableDeclarator.parent.parent && variableDeclarator.parent.parent.parent && variableDeclarator.parent.kind() === 2 /* SeparatedList */ && variableDeclarator.parent.parent.kind() === 224 /* VariableDeclaration */ && variableDeclarator.parent.parent.parent.kind() === 148 /* VariableStatement */) { + return variableDeclarator.parent.parent.parent; + } + + return null; + } + + function getVariableDeclaratorModifiers(variableDeclarator) { + var variableStatement = getVariableStatement(variableDeclarator); + return variableStatement ? variableStatement.modifiers : TypeScript.sentinelEmptyArray; + } + ASTHelpers.getVariableDeclaratorModifiers = getVariableDeclaratorModifiers; + + function isIntegerLiteralAST(expression) { + if (expression) { + switch (expression.kind()) { + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + expression = expression.operand; + return expression.kind() === 13 /* NumericLiteral */ && TypeScript.IntegerUtilities.isInteger(expression.text()); + + case 13 /* NumericLiteral */: + var text = expression.text(); + return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); + } + } + + return false; + } + ASTHelpers.isIntegerLiteralAST = isIntegerLiteralAST; + + function getEnclosingModuleDeclaration(ast) { + while (ast) { + if (ast.kind() === 130 /* ModuleDeclaration */) { + return ast; } - return docComments.reverse(); - } - } - - return TypeScript.sentinelEmptyArray; - } - TypeScript.docComments = docComments; - - function isDocComment(comment) { - if (comment.kind() === 6 /* MultiLineCommentTrivia */) { - var fullText = comment.fullText(); - return fullText.charAt(2) === "*" && fullText.charAt(3) !== "/"; - } - - return false; - } - - function getParameterList(ast) { - if (ast) { - switch (ast.kind()) { - case 137 /* ConstructorDeclaration */: - return ast.parameterList; - case 129 /* FunctionDeclaration */: - return getParameterList(ast.callSignature); - case 218 /* ParenthesizedArrowFunctionExpression */: - return getParameterList(ast.callSignature); - case 143 /* ConstructSignature */: - return getParameterList(ast.callSignature); - case 135 /* MemberFunctionDeclaration */: - return getParameterList(ast.callSignature); - case 241 /* FunctionPropertyAssignment */: - return getParameterList(ast.callSignature); - case 222 /* FunctionExpression */: - return getParameterList(ast.callSignature); - case 145 /* MethodSignature */: - return getParameterList(ast.callSignature); - case 125 /* ConstructorType */: - return ast.parameterList; - case 123 /* FunctionType */: - return ast.parameterList; - case 142 /* CallSignature */: - return ast.parameterList; - case 139 /* GetAccessor */: - return ast.parameterList; - case 140 /* SetAccessor */: - return ast.parameterList; - } - } - - return null; - } - TypeScript.getParameterList = getParameterList; - - function getType(ast) { - if (ast) { - switch (ast.kind()) { - case 129 /* FunctionDeclaration */: - return getType(ast.callSignature); - case 218 /* ParenthesizedArrowFunctionExpression */: - return getType(ast.callSignature); - case 143 /* ConstructSignature */: - return getType(ast.callSignature); - case 135 /* MemberFunctionDeclaration */: - return getType(ast.callSignature); - case 241 /* FunctionPropertyAssignment */: - return getType(ast.callSignature); - case 222 /* FunctionExpression */: - return getType(ast.callSignature); - case 145 /* MethodSignature */: - return getType(ast.callSignature); - case 142 /* CallSignature */: - return getType(ast.typeAnnotation); - case 144 /* IndexSignature */: - return getType(ast.typeAnnotation); - case 141 /* PropertySignature */: - return getType(ast.typeAnnotation); - case 139 /* GetAccessor */: - return getType(ast.typeAnnotation); - case 242 /* Parameter */: - return getType(ast.typeAnnotation); - case 136 /* MemberVariableDeclaration */: - return getType(ast.variableDeclarator); - case 225 /* VariableDeclarator */: - return getType(ast.typeAnnotation); - case 236 /* CatchClause */: - return getType(ast.typeAnnotation); - case 125 /* ConstructorType */: - return ast.type; - case 123 /* FunctionType */: - return ast.type; - case 244 /* TypeAnnotation */: - return ast.type; - } - } - - return null; - } - TypeScript.getType = getType; - - function getVariableStatement(variableDeclarator) { - if (variableDeclarator && variableDeclarator.parent && variableDeclarator.parent.parent && variableDeclarator.parent.parent.parent && variableDeclarator.parent.kind() === 2 /* SeparatedList */ && variableDeclarator.parent.parent.kind() === 224 /* VariableDeclaration */ && variableDeclarator.parent.parent.parent.kind() === 148 /* VariableStatement */) { - return variableDeclarator.parent.parent.parent; - } - - return null; - } - - function getVariableDeclaratorModifiers(variableDeclarator) { - var variableStatement = getVariableStatement(variableDeclarator); - return variableStatement ? variableStatement.modifiers : TypeScript.sentinelEmptyArray; - } - TypeScript.getVariableDeclaratorModifiers = getVariableDeclaratorModifiers; - - function isIntegerLiteralAST(expression) { - if (expression) { - switch (expression.kind()) { - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - expression = expression.operand; - return expression.kind() === 13 /* NumericLiteral */ && TypeScript.IntegerUtilities.isInteger(expression.text()); - - case 13 /* NumericLiteral */: - var text = expression.text(); - return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); - } - } - - return false; - } - TypeScript.isIntegerLiteralAST = isIntegerLiteralAST; - - function getEnclosingModuleDeclaration(ast) { - while (ast) { - if (ast.kind() === 130 /* ModuleDeclaration */) { - return ast; + ast = ast.parent; } - ast = ast.parent; + return null; } + ASTHelpers.getEnclosingModuleDeclaration = getEnclosingModuleDeclaration; - return null; - } - TypeScript.getEnclosingModuleDeclaration = getEnclosingModuleDeclaration; + function isLastNameOfModule(ast, astName) { + if (ast) { + if (ast.stringLiteral) { + return astName === ast.stringLiteral; + } else { + var moduleNames = TypeScript.getModuleNames(ast.name); + var nameIndex = moduleNames.indexOf(astName); - function isLastNameOfModule(ast, astName) { - if (ast) { - if (ast.stringLiteral) { - return astName === ast.stringLiteral; + return nameIndex === (moduleNames.length - 1); + } + } + + return false; + } + ASTHelpers.isLastNameOfModule = isLastNameOfModule; + + function isAnyNameOfModule(ast, astName) { + if (ast) { + if (ast.stringLiteral) { + return ast.stringLiteral === astName; + } else { + var moduleNames = TypeScript.getModuleNames(ast.name); + var nameIndex = moduleNames.indexOf(astName); + + return nameIndex >= 0; + } + } + + return false; + } + ASTHelpers.isAnyNameOfModule = isAnyNameOfModule; + + function getNameOfIdenfierOrQualifiedName(name) { + if (name.kind() === 11 /* IdentifierName */) { + return name.text(); } else { - var moduleNames = TypeScript.getModuleNames(ast.name); - var nameIndex = moduleNames.indexOf(astName); - - return nameIndex === (moduleNames.length - 1); + TypeScript.Debug.assert(name.kind() == 121 /* QualifiedName */); + var dotExpr = name; + return getNameOfIdenfierOrQualifiedName(dotExpr.left) + "." + getNameOfIdenfierOrQualifiedName(dotExpr.right); } } - - return false; - } - TypeScript.isLastNameOfModule = isLastNameOfModule; - - function isAnyNameOfModule(ast, astName) { - if (ast) { - if (ast.stringLiteral) { - return ast.stringLiteral === astName; - } else { - var moduleNames = TypeScript.getModuleNames(ast.name); - var nameIndex = moduleNames.indexOf(astName); - - return nameIndex >= 0; - } - } - - return false; - } - TypeScript.isAnyNameOfModule = isAnyNameOfModule; + ASTHelpers.getNameOfIdenfierOrQualifiedName = getNameOfIdenfierOrQualifiedName; + })(TypeScript.ASTHelpers || (TypeScript.ASTHelpers = {})); + var ASTHelpers = TypeScript.ASTHelpers; })(TypeScript || (TypeScript = {})); var TypeScript; (function (TypeScript) { @@ -28619,7 +28699,7 @@ var TypeScript; } function walkConstructorDeclarationChildren(preAst, walker) { - walker.walk(preAst.parameterList); + walker.walk(preAst.callSignature); walker.walk(preAst.block); } @@ -29412,9 +29492,17 @@ var TypeScript; var settings = compiler.compilationSettings(); this._settings = settings; - if (settings.moduleGenTarget() === 0 /* Unspecified */ && compiler._isDynamicModuleCompilation()) { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Cannot_compile_external_modules_unless_the_module_flag_is_provided, null); - return; + if (settings.moduleGenTarget() === 0 /* Unspecified */) { + var fileNames = compiler.fileNames(); + for (var i = 0, n = fileNames.length; i < n; i++) { + var document = compiler.getDocument(fileNames[i]); + if (!document.isDeclareFile() && document.isExternalModule()) { + var errorSpan = document.externalModuleIndicatorSpan(); + this._diagnostic = new TypeScript.Diagnostic(document.fileName, document.lineMap(), errorSpan.start(), errorSpan.length(), TypeScript.DiagnosticCode.Cannot_compile_external_modules_unless_the_module_flag_is_provided); + + return; + } + } } if (!settings.mapSourceFiles()) { @@ -29496,7 +29584,7 @@ var TypeScript; updatedPath = true; if (j === 0) { - if (this._outputDirectory || this._sourceRootDirectory || (this._sourceMapRootDirectory && (!this._sharedOutputFile || compiler._isDynamicModuleCompilation()))) { + if (this._outputDirectory || this._sourceMapRootDirectory) { this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Cannot_find_the_common_subdirectory_path_for_the_input_files, null); return; } @@ -29573,10 +29661,10 @@ var TypeScript; this.sourceMapper = null; this.captureThisStmtString = "var _this = this;"; this.declStack = []; - this.exportAssignmentIdentifier = null; + this.exportAssignment = null; this.inWithBlock = false; this.document = null; - this.copyrightElement = null; + this.detachedCommentsElement = null; } Emitter.prototype.pushDecl = function (decl) { if (decl) { @@ -29596,12 +29684,12 @@ var TypeScript; return enclosingDecl; }; - Emitter.prototype.setExportAssignmentIdentifier = function (id) { - this.exportAssignmentIdentifier = id; + Emitter.prototype.setExportAssignment = function (exportAssignment) { + this.exportAssignment = exportAssignment; }; - Emitter.prototype.getExportAssignmentIdentifier = function () { - return this.exportAssignmentIdentifier; + Emitter.prototype.getExportAssignment = function () { + return this.exportAssignment; }; Emitter.prototype.setDocument = function (document) { @@ -29609,14 +29697,46 @@ var TypeScript; }; Emitter.prototype.shouldEmitImportDeclaration = function (importDeclAST) { - return TypeScript.importDeclarationIsElided(importDeclAST, this.semanticInfoChain, this.emitOptions.compilationSettings()); + var isExternalModuleReference = importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */; + var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST); + var isExported = TypeScript.hasFlag(importDecl.flags, 1 /* Exported */); + var isAmdCodeGen = this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */; + + if (isExternalModuleReference && !isExported && isAmdCodeGen) { + return false; + } + + var importSymbol = importDecl.getSymbol(); + if (importSymbol.isUsedAsValue()) { + return true; + } + + if (importDeclAST.moduleReference.kind() !== 245 /* ExternalModuleReference */) { + var canBeUsedExternally = isExported || importSymbol.typeUsedExternally() || importSymbol.isUsedInExportedAlias(); + if (!canBeUsedExternally && !this.document.isExternalModule()) { + canBeUsedExternally = TypeScript.hasFlag(importDecl.getParentDecl().kind, 1 /* Script */ | 32 /* DynamicModule */); + } + + if (canBeUsedExternally) { + if (importSymbol.getExportAssignedValueSymbol()) { + return true; + } + + var containerSymbol = importSymbol.getExportAssignedContainerSymbol(); + if (containerSymbol && containerSymbol.getInstanceSymbol()) { + return true; + } + } + } + + return false; }; Emitter.prototype.emitImportDeclaration = function (importDeclAST) { var isExternalModuleReference = importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */; var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST); var isExported = TypeScript.hasFlag(importDecl.flags, 1 /* Exported */); - var isAmdCodeGen = this.emitOptions.compilationSettings().moduleGenTarget() == 2 /* Asynchronous */; + var isAmdCodeGen = this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */; this.emitComments(importDeclAST, true); @@ -29631,12 +29751,12 @@ var TypeScript; var usePropertyAssignmentInsteadOfVarDecl = false; var moduleNamePrefix; - if (isExported && (parentKind == 4 /* Container */ || parentKind === 32 /* DynamicModule */ || associatedParentSymbolKind === 4 /* Container */ || associatedParentSymbolKind === 32 /* DynamicModule */)) { + if (isExported && (parentKind === 4 /* Container */ || parentKind === 32 /* DynamicModule */ || associatedParentSymbolKind === 4 /* Container */ || associatedParentSymbolKind === 32 /* DynamicModule */)) { if (importSymbol.getExportAssignedTypeSymbol() || importSymbol.getExportAssignedContainerSymbol()) { needsPropertyAssignment = true; } else { var valueSymbol = importSymbol.getExportAssignedValueSymbol(); - if (valueSymbol && (valueSymbol.kind == 65536 /* Method */ || valueSymbol.kind == 16384 /* Function */)) { + if (valueSymbol && (valueSymbol.kind === 65536 /* Method */ || valueSymbol.kind === 16384 /* Function */)) { needsPropertyAssignment = true; } else { usePropertyAssignmentInsteadOfVarDecl = true; @@ -29783,14 +29903,14 @@ var TypeScript; this.writeLineToOutput(""); } - if (!trailing && emitColumn != 0) { + if (!trailing && emitColumn !== 0) { this.emitIndent(); } }; Emitter.prototype.emitComments = function (ast, pre, onlyPinnedOrTripleSlashComments) { - if (typeof onlyPinnedOrTripleSlashComments === "undefined") { onlyPinnedOrTripleSlashComments = false; } var _this = this; + if (typeof onlyPinnedOrTripleSlashComments === "undefined") { onlyPinnedOrTripleSlashComments = false; } if (ast && ast.kind() !== 146 /* Block */) { if (ast.parent.kind() === 219 /* SimpleArrowFunctionExpression */ || ast.parent.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { return; @@ -29800,12 +29920,13 @@ var TypeScript; if (pre) { var preComments = ast.preComments(); - if (preComments && ast === this.copyrightElement) { - var copyrightComments = this.getCopyrightComments(); - preComments = preComments.slice(copyrightComments.length); + if (preComments && ast === this.detachedCommentsElement) { + var detachedComments = this.getDetachedComments(ast); + preComments = preComments.slice(detachedComments.length); + this.detachedCommentsElement = null; } - if (onlyPinnedOrTripleSlashComments) { + if (preComments && onlyPinnedOrTripleSlashComments) { preComments = TypeScript.ArrayUtilities.where(preComments, function (c) { return _this.isPinnedOrTripleSlash(c); }); @@ -29946,7 +30067,7 @@ var TypeScript; Emitter.prototype.emitParameterList = function (list) { this.writeToOutput("("); this.emitCommentsArray(list.openParenTrailingComments, true); - this.emitFunctionParameters(TypeScript.Parameters.fromParameterList(list)); + this.emitFunctionParameters(TypeScript.ASTHelpers.parametersFromParameterList(list)); this.writeToOutput(")"); }; @@ -29984,15 +30105,19 @@ var TypeScript; this.indenter.increaseIndent(); - if (parameterList) { - this.emitDefaultValueAssignments(parameterList); - this.emitRestParameterInitializer(parameterList); + if (block) { + this.emitDetachedComments(block.statements); } if (this.shouldCaptureThis(funcDecl)) { this.writeCaptureThisStatement(funcDecl); } + if (parameterList) { + this.emitDefaultValueAssignments(parameterList); + this.emitRestParameterInitializer(parameterList); + } + if (block) { this.emitList(block.statements); this.emitCommentsArray(block.closeBraceLeadingComments, false); @@ -30243,12 +30368,24 @@ var TypeScript; return null; }; - Emitter.prototype.hasChildNameCollision = function (moduleName, childDecls) { + Emitter.prototype.hasChildNameCollision = function (moduleName, parentDecl) { var _this = this; + var childDecls = parentDecl.getChildDecls(); return TypeScript.ArrayUtilities.any(childDecls, function (childDecl) { - if (childDecl.name == moduleName) { - var childAST = _this.semanticInfoChain.getASTForDecl(childDecl); - if (_this.shouldEmit(childAST)) { + var childAST = _this.semanticInfoChain.getASTForDecl(childDecl); + + if (childDecl.kind != 67108864 /* EnumMember */ && _this.shouldEmit(childAST)) { + if (childDecl.name === moduleName) { + if (parentDecl.kind != 8 /* Class */) { + return true; + } + + if (!(childDecl.kind == 65536 /* Method */ || childDecl.kind == 4096 /* Property */ || childDecl.kind == 524288 /* SetAccessor */ || childDecl.kind == 262144 /* GetAccessor */)) { + return true; + } + } + + if (_this.hasChildNameCollision(moduleName, childDecl)) { return true; } } @@ -30261,10 +30398,8 @@ var TypeScript; var moduleDisplayName = moduleDecl.getDisplayName(); moduleDecl = this.getModuleDeclToVerifyChildNameCollision(moduleDecl, changeNameIfAnyDeclarationInContext); - if (moduleDecl) { - var childDecls = moduleDecl.getChildDecls(); - - while (this.hasChildNameCollision(moduleName, childDecls)) { + if (moduleDecl && moduleDecl.kind != 64 /* Enum */) { + while (this.hasChildNameCollision(moduleName, moduleDecl)) { moduleName = "_" + moduleName; moduleDisplayName = "_" + moduleDisplayName; } @@ -30283,7 +30418,7 @@ var TypeScript; }; Emitter.prototype.emitSingleModuleDeclaration = function (moduleDecl, moduleName) { - var isLastName = TypeScript.isLastNameOfModule(moduleDecl, moduleName); + var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDecl, moduleName); if (isLastName) { this.emitComments(moduleDecl, true); @@ -30444,11 +30579,11 @@ var TypeScript; }; Emitter.prototype.emitSimpleArrowFunctionExpression = function (arrowFunction) { - this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.Parameters.fromIdentifier(arrowFunction.identifier), arrowFunction.block, arrowFunction.expression); + this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), arrowFunction.block, arrowFunction.expression); }; Emitter.prototype.emitParenthesizedArrowFunctionExpression = function (arrowFunction) { - this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.Parameters.fromParameterList(arrowFunction.callSignature.parameterList), arrowFunction.block, arrowFunction.expression); + this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromParameterList(arrowFunction.callSignature.parameterList), arrowFunction.block, arrowFunction.expression); }; Emitter.prototype.emitAnyArrowFunctionExpression = function (arrowFunction, funcName, parameters, block, expression) { @@ -30500,7 +30635,7 @@ var TypeScript; this.writeToOutput("function "); this.writeToOutput(this.thisClassNode.identifier.text()); this.writeToOutput("("); - var parameters = TypeScript.Parameters.fromParameterList(funcDecl.parameterList); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); this.emitFunctionParameters(parameters); this.writeLineToOutput(") {"); @@ -30554,7 +30689,7 @@ var TypeScript; this.writeToOutput("("); this.writeToOutput(")"); - this.emitFunctionBodyStatements(null, accessor, TypeScript.Parameters.fromParameterList(accessor.parameterList), accessor.block, null); + this.emitFunctionBodyStatements(null, accessor, TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList), accessor.block, null); this.recordSourceMappingEnd(accessor); @@ -30586,7 +30721,7 @@ var TypeScript; this.writeToOutput(accessor.propertyName.text()); this.writeToOutput("("); - var parameters = TypeScript.Parameters.fromParameterList(accessor.parameterList); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList); this.emitFunctionParameters(parameters); this.writeToOutput(")"); @@ -30625,7 +30760,7 @@ var TypeScript; this.writeToOutput("("); - var parameters = TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); this.emitFunctionParameters(parameters); this.writeToOutput(")"); @@ -30680,7 +30815,7 @@ var TypeScript; this.emitParameterList(funcDecl.callSignature.parameterList); - var parameters = TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); this.emitFunctionBodyStatements(funcDecl.identifier.text(), funcDecl, parameters, funcDecl.block, null); this.recordSourceMappingEnd(funcDecl); @@ -30953,7 +31088,7 @@ var TypeScript; if (pullSymbol && pullSymbolAlias) { var symbolToCompare = TypeScript.isTypesOnlyLocation(ast) ? pullSymbolAlias.getExportAssignedTypeSymbol() : pullSymbolAlias.getExportAssignedValueSymbol(); - if (pullSymbol == symbolToCompare) { + if (pullSymbol === symbolToCompare) { pullSymbol = pullSymbolAlias; pullSymbolAlias = null; } @@ -30972,7 +31107,7 @@ var TypeScript; } var pullSymbolAlias = symbolForEmit.aliasSymbol; var pullSymbolKind = pullSymbol.kind; - var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() == this.getEnclosingDecl()); + var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() === this.getEnclosingDecl()); if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { var pullSymbolContainer = pullSymbol.getContainer(); @@ -31017,19 +31152,19 @@ var TypeScript; if (name) { if (this.sourceMapper.currentNameIndex.length > 0) { var parentNameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; - if (parentNameIndex != -1) { + if (parentNameIndex !== -1) { name = this.sourceMapper.names[parentNameIndex] + "." + name; } } var nameIndex = this.sourceMapper.names.length - 1; for (nameIndex; nameIndex >= 0; nameIndex--) { - if (this.sourceMapper.names[nameIndex] == name) { + if (this.sourceMapper.names[nameIndex] === name) { break; } } - if (nameIndex == -1) { + if (nameIndex === -1) { nameIndex = this.sourceMapper.names.length; this.sourceMapper.names.push(name); } @@ -31045,7 +31180,7 @@ var TypeScript; }; Emitter.prototype.recordSourceMappingStart = function (ast) { - if (this.sourceMapper && TypeScript.isValidAstNode(ast)) { + if (this.sourceMapper && TypeScript.ASTHelpers.isValidAstNode(ast)) { var lineCol = { line: -1, character: -1 }; var sourceMapping = new TypeScript.SourceMapping(); sourceMapping.start.emittedColumn = this.emitState.column; @@ -31078,7 +31213,7 @@ var TypeScript; }; Emitter.prototype.recordSourceMappingEnd = function (ast) { - if (this.sourceMapper && TypeScript.isValidAstNode(ast)) { + if (this.sourceMapper && TypeScript.ASTHelpers.isValidAstNode(ast)) { this.sourceMapper.currentMappings.pop(); var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; @@ -31108,9 +31243,9 @@ var TypeScript; Emitter.prototype.emitParameterPropertyAndMemberVariableAssignments = function () { var constructorDecl = getLastConstructor(this.thisClassNode); - if (constructorDecl && constructorDecl.parameterList) { - for (var i = 0, n = constructorDecl.parameterList.parameters.nonSeparatorCount(); i < n; i++) { - var parameter = constructorDecl.parameterList.parameters.nonSeparatorAt(i); + if (constructorDecl) { + for (var i = 0, n = constructorDecl.callSignature.parameterList.parameters.nonSeparatorCount(); i < n; i++) { + var parameter = constructorDecl.callSignature.parameterList.parameters.nonSeparatorAt(i); var parameterDecl = this.semanticInfoChain.getDeclForAST(parameter); if (TypeScript.hasFlag(parameterDecl.flags, 8388608 /* PropertyParameter */)) { this.emitIndent(); @@ -31270,12 +31405,12 @@ var TypeScript; } }; - Emitter.prototype.getCopyrightComments = function () { - var preComments = this.copyrightElement.preComments(); + Emitter.prototype.getDetachedComments = function (element) { + var preComments = element.preComments(); if (preComments) { var lineMap = this.document.lineMap(); - var copyrightComments = []; + var detachedComments = []; var lastComment = null; for (var i = 0, n = preComments.length; i < n; i++) { @@ -31286,18 +31421,18 @@ var TypeScript; var commentLine = lineMap.getLineNumberFromPosition(comment.start()); if (commentLine >= lastCommentLine + 2) { - return copyrightComments; + return detachedComments; } } - copyrightComments.push(comment); + detachedComments.push(comment); lastComment = comment; } - var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(copyrightComments).end()); - var astLine = lineMap.getLineNumberFromPosition(this.copyrightElement.start()); + var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(detachedComments).end()); + var astLine = lineMap.getLineNumberFromPosition(element.start()); if (astLine >= lastCommentLine + 2) { - return copyrightComments; + return detachedComments; } } @@ -31305,12 +31440,15 @@ var TypeScript; }; Emitter.prototype.emitPossibleCopyrightHeaders = function (script) { - var list = script.moduleElements; + this.emitDetachedComments(script.moduleElements); + }; + + Emitter.prototype.emitDetachedComments = function (list) { if (list.childCount() > 0) { var firstElement = list.childAt(0); - this.copyrightElement = firstElement; - this.emitCommentsArray(this.getCopyrightComments(), false); + this.detachedCommentsElement = firstElement; + this.emitCommentsArray(this.getDetachedComments(this.detachedCommentsElement), false); } }; @@ -31333,7 +31471,7 @@ var TypeScript; this.emitPrologue(sourceUnit); var isExternalModule = this.document.isExternalModule(); - var isNonElidedExternalModule = isExternalModule && !TypeScript.scriptIsElided(sourceUnit); + var isNonElidedExternalModule = isExternalModule && !TypeScript.ASTHelpers.scriptIsElided(sourceUnit); if (isNonElidedExternalModule) { this.recordSourceMappingStart(sourceUnit); @@ -31358,7 +31496,7 @@ var TypeScript; this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); } - this.setExportAssignmentIdentifier(null); + this.setExportAssignment(null); if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { this.indenter.increaseIndent(); @@ -31381,20 +31519,23 @@ var TypeScript; } if (isNonElidedExternalModule) { - var exportAssignmentIdentifier = this.getExportAssignmentIdentifier(); + var exportAssignment = this.getExportAssignment(); + var exportAssignmentIdentifierText = exportAssignment ? exportAssignment.identifier.text() : null; var exportAssignmentValueSymbol = externalModule.getSymbol().getExportAssignedValueSymbol(); if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - if (exportAssignmentIdentifier && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { + if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { this.indenter.increaseIndent(); this.emitIndent(); - this.writeLineToOutput("return " + exportAssignmentIdentifier + ";"); + this.writeToOutputWithSourceMapRecord("return " + exportAssignmentIdentifierText, exportAssignment); + this.writeLineToOutput(";"); this.indenter.decreaseIndent(); } this.writeToOutput("});"); - } else if (exportAssignmentIdentifier && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { + } else if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { this.emitIndent(); - this.writeToOutput("module.exports = " + exportAssignmentIdentifier + ";"); + this.writeToOutputWithSourceMapRecord("module.exports = " + exportAssignmentIdentifierText, exportAssignment); + this.writeToOutput(";"); } this.recordSourceMappingEnd(sourceUnit); @@ -31416,7 +31557,7 @@ var TypeScript; this.emitComments(list, true); - var emitPropertyAssignmentsAfterSuperCall = TypeScript.getExtendsHeritageClause(this.thisClassNode.heritageClauses) !== null; + var emitPropertyAssignmentsAfterSuperCall = TypeScript.ASTHelpers.getExtendsHeritageClause(this.thisClassNode.heritageClauses) !== null; var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; var lastEmittedNode = null; @@ -31523,7 +31664,7 @@ var TypeScript; this.writeToOutput("("); - var parameters = TypeScript.Parameters.fromParameterList(parameterList); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(parameterList); this.emitFunctionParameters(parameters); this.writeToOutput(")"); @@ -31548,7 +31689,7 @@ var TypeScript; this.recordSourceMappingStart(classDecl); this.writeToOutput("var " + className); - var hasBaseClass = TypeScript.getExtendsHeritageClause(classDecl.heritageClauses) !== null; + var hasBaseClass = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses) !== null; var baseTypeReference = null; var varDecl = null; @@ -31562,9 +31703,10 @@ var TypeScript; this.indenter.increaseIndent(); if (hasBaseClass) { - baseTypeReference = TypeScript.getExtendsHeritageClause(classDecl.heritageClauses).typeNames.nonSeparatorAt(0); + baseTypeReference = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses).typeNames.nonSeparatorAt(0); this.emitIndent(); - this.writeLineToOutput("__extends(" + className + ", _super);"); + this.writeToOutputWithSourceMapRecord("__extends(" + className + ", _super)", baseTypeReference); + this.writeLineToOutput(";"); } this.emitIndent(); @@ -31582,7 +31724,8 @@ var TypeScript; this.recordSourceMappingNameStart("constructor"); if (hasBaseClass) { this.emitIndent(); - this.writeLineToOutput("_super.apply(this, arguments);"); + this.writeToOutputWithSourceMapRecord("_super.apply(this, arguments)", baseTypeReference); + this.writeLineToOutput(";"); } if (this.shouldCaptureThis(classDecl)) { @@ -31593,7 +31736,8 @@ var TypeScript; this.indenter.decreaseIndent(); this.emitIndent(); - this.writeLineToOutput("}"); + this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); + this.writeLineToOutput(""); this.recordSourceMappingNameEnd(); this.recordSourceMappingEnd(classDecl); @@ -31715,7 +31859,7 @@ var TypeScript; this.emitParameterList(funcDecl.callSignature.parameterList); - var parameters = TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); this.emitFunctionBodyStatements(funcDecl.propertyName.text(), funcDecl, parameters, funcDecl.block, null); this.recordSourceMappingEnd(funcDecl); @@ -31741,7 +31885,7 @@ var TypeScript; } else if (moduleElement.kind() === 131 /* ClassDeclaration */) { var classDeclaration = moduleElement; - if (!TypeScript.hasModifier(classDeclaration.modifiers, 8 /* Ambient */) && TypeScript.getExtendsHeritageClause(classDeclaration.heritageClauses) !== null) { + if (!TypeScript.hasModifier(classDeclaration.modifiers, 8 /* Ambient */) && TypeScript.ASTHelpers.getExtendsHeritageClause(classDeclaration.heritageClauses) !== null) { return true; } } @@ -31921,13 +32065,13 @@ var TypeScript; Emitter.prototype.canEmitDottedNameMemberAccessExpression = function (expression) { var memberExpressionNodeType = expression.expression.kind(); - if (memberExpressionNodeType == 11 /* IdentifierName */ || memberExpressionNodeType == 212 /* MemberAccessExpression */) { + if (memberExpressionNodeType === 11 /* IdentifierName */ || memberExpressionNodeType == 212 /* MemberAccessExpression */) { var memberAccessSymbol = this.getSymbolForEmit(expression).symbol; var memberAccessExpressionSymbol = this.getSymbolForEmit(expression.expression).symbol; if (memberAccessSymbol && memberAccessExpressionSymbol && !this.semanticInfoChain.getAliasSymbolForAST(expression.expression) && (TypeScript.PullHelpers.symbolIsModule(memberAccessExpressionSymbol) || memberAccessExpressionSymbol.kind === 64 /* Enum */ || memberAccessExpressionSymbol.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */))) { var memberAccessSymbolKind = memberAccessSymbol.kind; if (memberAccessSymbolKind === 4096 /* Property */ || memberAccessSymbolKind === 67108864 /* EnumMember */ || (memberAccessSymbol.anyDeclHasFlag(1 /* Exported */) && memberAccessSymbolKind === 512 /* Variable */ && !memberAccessSymbol.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) || ((memberAccessSymbol.anyDeclHasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(memberAccessSymbol)))) { - if (memberExpressionNodeType == 212 /* MemberAccessExpression */) { + if (memberExpressionNodeType === 212 /* MemberAccessExpression */) { return this.canEmitDottedNameMemberAccessExpression(expression.expression); } @@ -31941,7 +32085,7 @@ var TypeScript; Emitter.prototype.emitDottedNameMemberAccessExpressionWorker = function (expression, potentialPath, startingIndex, lastIndex) { this.recordSourceMappingStart(expression); - if (expression.expression.kind() == 212 /* MemberAccessExpression */) { + if (expression.expression.kind() === 212 /* MemberAccessExpression */) { this.emitDottedNameMemberAccessExpressionRecurse(expression.expression, potentialPath, startingIndex, lastIndex - 1); } else { this.emitComments(expression.expression, true); @@ -32058,7 +32202,7 @@ var TypeScript; this.writeToOutput("("); - var parameters = TypeScript.Parameters.fromParameterList(funcProp.callSignature.parameterList); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcProp.callSignature.parameterList); this.emitFunctionParameters(parameters); this.writeToOutput(")"); @@ -32074,8 +32218,6 @@ var TypeScript; this.setContainer(temp); this.inArrowFunction = savedInArrowFunction; - - this.recordSourceMappingEnd(funcProp); }; Emitter.prototype.emitConditionalExpression = function (expression) { @@ -32396,15 +32538,17 @@ var TypeScript; this.pushDecl(pullDecl); this.emitScriptElements(sourceUnit); this.popDecl(pullDecl); + + this.emitCommentsArray(sourceUnit.endOfFileTokenLeadingComments, false); } }; Emitter.prototype.shouldEmitEnumDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.enumIsElided(declaration); + return declaration.preComments() !== null || !TypeScript.ASTHelpers.enumIsElided(declaration); }; Emitter.prototype.emitEnumDeclaration = function (declaration) { - if (!TypeScript.enumIsElided(declaration)) { + if (!TypeScript.ASTHelpers.enumIsElided(declaration)) { this.emitComments(declaration, true); this.emitEnum(declaration); this.emitComments(declaration, false); @@ -32414,11 +32558,11 @@ var TypeScript; }; Emitter.prototype.shouldEmitModuleDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.moduleIsElided(declaration); + return declaration.preComments() !== null || !TypeScript.ASTHelpers.moduleIsElided(declaration); }; Emitter.prototype.emitModuleDeclaration = function (declaration) { - if (!TypeScript.moduleIsElided(declaration)) { + if (!TypeScript.ASTHelpers.moduleIsElided(declaration)) { this.emitModuleDeclarationWorker(declaration); } else { this.emitComments(declaration, true, true); @@ -32514,7 +32658,7 @@ var TypeScript; case 133 /* ImportDeclaration */: return this.emitImportDeclaration(ast); case 134 /* ExportAssignment */: - return this.setExportAssignmentIdentifier(ast.identifier.text()); + return this.setExportAssignment(ast); case 131 /* ClassDeclaration */: return this.emitClassDeclaration(ast); case 128 /* InterfaceDeclaration */: @@ -33253,10 +33397,10 @@ var TypeScript; var dtsFile = normalizedPath + ".d.ts"; var tsFile = normalizedPath + ".ts"; - if (this.host.fileExists(dtsFile)) { - normalizedPath = dtsFile; - } else { + if (this.host.fileExists(tsFile)) { normalizedPath = tsFile; + } else { + normalizedPath = dtsFile; } } @@ -33286,13 +33430,13 @@ var TypeScript; var start = new Date().getTime(); do { - var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); + currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); if (this.host.fileExists(currentFilePath)) { searchFilePath = currentFilePath; break; } - currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); + var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); if (this.host.fileExists(currentFilePath)) { searchFilePath = currentFilePath; break; @@ -33544,7 +33688,7 @@ var TypeScript; var declAST = this.semanticInfoChain.getASTForDecl(pullDecl); var container = this.getEnclosingContainer(declAST); - if (container.kind() === 130 /* ModuleDeclaration */ && TypeScript.isAnyNameOfModule(container, declAST)) { + if (container.kind() === 130 /* ModuleDeclaration */ && TypeScript.ASTHelpers.isAnyNameOfModule(container, declAST)) { container = this.getEnclosingContainer(container); } @@ -33555,8 +33699,8 @@ var TypeScript; emitDeclare = true; } - if (isExternalModule || container.kind() == 120 /* SourceUnit */) { - if (emitDeclare && typeString !== "interface" && typeString != "import") { + if (isExternalModule || container.kind() === 120 /* SourceUnit */) { + if (emitDeclare && typeString !== "interface" && typeString !== "import") { result += "declare "; } } @@ -33625,7 +33769,9 @@ var TypeScript; var declarationPullSymbol = declarationContainerDecl.getSymbol(); TypeScript.declarationEmitTypeSignatureTime += new Date().getTime() - start; - var typeNameMembers = type.getScopedNameEx(declarationPullSymbol); + var isNotAGenericType = ast.kind() !== 126 /* GenericType */; + + var typeNameMembers = type.getScopedNameEx(declarationPullSymbol, false, false, false, false, false, isNotAGenericType); this.emitTypeNamesMember(typeNameMembers); }; @@ -33659,7 +33805,7 @@ var TypeScript; return; } - var declComments = astOrSymbol.docComments ? astOrSymbol.docComments() : TypeScript.docComments(astOrSymbol); + var declComments = astOrSymbol.docComments ? astOrSymbol.docComments() : TypeScript.ASTHelpers.docComments(astOrSymbol); this.writeDeclarationComments(declComments, endLine); }; @@ -33718,7 +33864,7 @@ var TypeScript; this.declFile.Write(varDecl.propertyName.text()); - if (!TypeScript.hasModifier(TypeScript.getVariableDeclaratorModifiers(varDecl), 2 /* Private */)) { + if (!TypeScript.hasModifier(TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl), 2 /* Private */)) { this.emitTypeOfVariableDeclaratorOrParameter(varDecl); } @@ -33770,7 +33916,7 @@ var TypeScript; DeclarationEmitter.prototype.emitDeclarationsForVariableDeclaration = function (variableDeclaration) { var varListCount = variableDeclaration.declarators.nonSeparatorCount(); for (var i = 0; i < varListCount; i++) { - this.emitVariableDeclarator(variableDeclaration.declarators.nonSeparatorAt(i), i == 0, i == varListCount - 1); + this.emitVariableDeclarator(variableDeclaration.declarators.nonSeparatorAt(i), i === 0, i === varListCount - 1); } }; @@ -33825,14 +33971,14 @@ var TypeScript; this.declFile.Write("constructor"); this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.parameterList)); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); this.declFile.Write(")"); this.declFile.WriteLine(";"); }; DeclarationEmitter.prototype.emitParameterList = function (isPrivate, parameterList) { this.declFile.Write("("); - this.emitParameters(isPrivate, TypeScript.Parameters.fromParameterList(parameterList)); + this.emitParameters(isPrivate, TypeScript.ASTHelpers.parametersFromParameterList(parameterList)); this.declFile.Write(")"); }; @@ -33923,7 +34069,7 @@ var TypeScript; this.emitIndent(); this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.parameterList)); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList)); this.declFile.Write(")"); var returnType = funcSignature.returnType; @@ -33954,7 +34100,7 @@ var TypeScript; this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList)); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); this.declFile.Write(")"); var returnType = funcSignature.returnType; @@ -33988,7 +34134,7 @@ var TypeScript; this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList)); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); this.declFile.Write(")"); var returnType = funcSignature.returnType; @@ -34038,7 +34184,7 @@ var TypeScript; this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList)); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); this.declFile.Write(")"); var returnType = funcSignature.returnType; @@ -34065,7 +34211,7 @@ var TypeScript; this.emitIndent(); this.declFile.Write("["); - this.emitParameters(false, TypeScript.Parameters.fromParameter(funcDecl.parameter)); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter)); this.declFile.Write("]"); var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); @@ -34104,10 +34250,10 @@ var TypeScript; var comments = []; if (accessors.getter) { - comments = comments.concat(TypeScript.docComments(accessors.getter)); + comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.getter)); } if (accessors.setter) { - comments = comments.concat(TypeScript.docComments(accessors.setter)); + comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.setter)); } this.writeDeclarationComments(comments); @@ -34144,27 +34290,25 @@ var TypeScript; }; DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { - if (funcDecl.parameterList) { - var argsLen = funcDecl.parameterList.parameters.nonSeparatorCount(); - if (TypeScript.lastParameterIsRest(funcDecl.parameterList)) { - argsLen--; - } + var argsLen = funcDecl.callSignature.parameterList.parameters.nonSeparatorCount(); + if (TypeScript.lastParameterIsRest(funcDecl.callSignature.parameterList)) { + argsLen--; + } - for (var i = 0; i < argsLen; i++) { - var parameter = funcDecl.parameterList.parameters.nonSeparatorAt(i); - var parameterDecl = this.semanticInfoChain.getDeclForAST(parameter); - if (TypeScript.hasFlag(parameterDecl.flags, 8388608 /* PropertyParameter */)) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.emitDeclarationComments(parameter); - this.declFile.Write(this.getIndentString()); - this.emitClassElementModifiers(parameter.modifiers); - this.declFile.Write(parameter.identifier.text()); + for (var i = 0; i < argsLen; i++) { + var parameter = funcDecl.callSignature.parameterList.parameters.nonSeparatorAt(i); + var parameterDecl = this.semanticInfoChain.getDeclForAST(parameter); + if (TypeScript.hasFlag(parameterDecl.flags, 8388608 /* PropertyParameter */)) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.emitDeclarationComments(parameter); + this.declFile.Write(this.getIndentString()); + this.emitClassElementModifiers(parameter.modifiers); + this.declFile.Write(parameter.identifier.text()); - if (!TypeScript.hasModifier(parameter.modifiers, 2 /* Private */)) { - this.emitTypeOfVariableDeclaratorOrParameter(parameter); - } - this.declFile.WriteLine(";"); + if (!TypeScript.hasModifier(parameter.modifiers, 2 /* Private */)) { + this.emitTypeOfVariableDeclaratorOrParameter(parameter); } + this.declFile.WriteLine(";"); } } }; @@ -34296,20 +34440,11 @@ var TypeScript; if (importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { this.declFile.WriteLine("require(" + importDeclAST.moduleReference.stringLiteral.text() + ");"); } else { - this.declFile.WriteLine(this.getFullName(importDeclAST.moduleReference.moduleName) + ";"); + this.declFile.WriteLine(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(importDeclAST.moduleReference.moduleName) + ";"); } } }; - DeclarationEmitter.prototype.getFullName = function (name) { - if (name.kind() === 11 /* IdentifierName */) { - return name.text(); - } else { - var dotExpr = name; - return this.getFullName(dotExpr.left) + "." + this.getFullName(dotExpr.right); - } - }; - DeclarationEmitter.prototype.emitDeclarationsForEnumDeclaration = function (moduleDecl) { if (!this.canEmitDeclarations(moduleDecl)) { return; @@ -34329,7 +34464,7 @@ var TypeScript; this.emitDeclarationComments(enumElement); this.emitIndent(); this.declFile.Write(enumElement.propertyName.text()); - if (enumElementDecl.constantValue != null) { + if (enumElementDecl.constantValue !== null) { this.declFile.Write(" = " + enumElementDecl.constantValue); } this.declFile.WriteLine(","); @@ -34354,7 +34489,7 @@ var TypeScript; if (moduleDecl.stringLiteral) { this.declFile.Write(moduleDecl.stringLiteral.text()); } else { - this.declFile.Write(this.getFullName(moduleDecl.name)); + this.declFile.Write(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(moduleDecl.name)); } this.declFile.WriteLine(" {"); @@ -34417,12 +34552,12 @@ var TypeScript; if (document && (document.isDeclareFile() || document.isExternalModule())) { for (var k = 0; k < documents.length; k++) { - if (documents[k] == document) { + if (documents[k] === document) { break; } } - if (k == documents.length) { + if (k === documents.length) { documents = documents.concat(document); } } @@ -34522,16 +34657,16 @@ var TypeScript; }; BloomFilter.prototype.isEquivalent = function (filter) { - return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount == filter.hashFunctionCount; + return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount === filter.hashFunctionCount; }; BloomFilter.isEquivalent = function (array1, array2) { - if (array1.length != array2.length) { + if (array1.length !== array2.length) { return false; } for (var i = 0; i < array1.length; i++) { - if (array1[i] != array2[i]) { + if (array1[i] !== array2[i]) { return false; } } @@ -34580,13 +34715,14 @@ var TypeScript; this.useCaseSensitiveFileResolution = false; this.gatherDiagnostics = false; this.codepage = null; + this.createFileLog = false; } return CompilationSettings; })(); TypeScript.CompilationSettings = CompilationSettings; var ImmutableCompilationSettings = (function () { - function ImmutableCompilationSettings(propagateEnumConstants, removeComments, watch, noResolve, allowAutomaticSemicolonInsertion, noImplicitAny, noLib, codeGenTarget, moduleGenTarget, outFileOption, outDirOption, mapSourceFiles, mapRoot, sourceRoot, generateDeclarationFiles, useCaseSensitiveFileResolution, gatherDiagnostics, codepage) { + function ImmutableCompilationSettings(propagateEnumConstants, removeComments, watch, noResolve, allowAutomaticSemicolonInsertion, noImplicitAny, noLib, codeGenTarget, moduleGenTarget, outFileOption, outDirOption, mapSourceFiles, mapRoot, sourceRoot, generateDeclarationFiles, useCaseSensitiveFileResolution, gatherDiagnostics, codepage, createFileLog) { this._propagateEnumConstants = propagateEnumConstants; this._removeComments = removeComments; this._watch = watch; @@ -34605,6 +34741,7 @@ var TypeScript; this._useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; this._gatherDiagnostics = gatherDiagnostics; this._codepage = codepage; + this._createFileLog = createFileLog; } ImmutableCompilationSettings.prototype.propagateEnumConstants = function () { return this._propagateEnumConstants; @@ -34660,6 +34797,9 @@ var TypeScript; ImmutableCompilationSettings.prototype.codepage = function () { return this._codepage; }; + ImmutableCompilationSettings.prototype.createFileLog = function () { + return this._createFileLog; + }; ImmutableCompilationSettings.defaultSettings = function () { if (!ImmutableCompilationSettings._defaultSettings) { @@ -34670,15 +34810,17 @@ var TypeScript; }; ImmutableCompilationSettings.fromCompilationSettings = function (settings) { - return new ImmutableCompilationSettings(settings.propagateEnumConstants, settings.removeComments, settings.watch, settings.noResolve, settings.allowAutomaticSemicolonInsertion, settings.noImplicitAny, settings.noLib, settings.codeGenTarget, settings.moduleGenTarget, settings.outFileOption, settings.outDirOption, settings.mapSourceFiles, settings.mapRoot, settings.sourceRoot, settings.generateDeclarationFiles, settings.useCaseSensitiveFileResolution, settings.gatherDiagnostics, settings.codepage); + return new ImmutableCompilationSettings(settings.propagateEnumConstants, settings.removeComments, settings.watch, settings.noResolve, settings.allowAutomaticSemicolonInsertion, settings.noImplicitAny, settings.noLib, settings.codeGenTarget, settings.moduleGenTarget, settings.outFileOption, settings.outDirOption, settings.mapSourceFiles, settings.mapRoot, settings.sourceRoot, settings.generateDeclarationFiles, settings.useCaseSensitiveFileResolution, settings.gatherDiagnostics, settings.codepage, settings.createFileLog); }; ImmutableCompilationSettings.prototype.toCompilationSettings = function () { var result = new CompilationSettings(); + var thisAsIndexable = this; + var resultAsIndexable = result; for (var name in this) { if (this.hasOwnProperty(name) && TypeScript.StringUtilities.startsWith(name, "_")) { - result[name.substr(1)] = this[name]; + resultAsIndexable[name.substr(1)] = thisAsIndexable[name]; } } @@ -34784,7 +34926,7 @@ var TypeScript; PullElementKind[PullElementKind["SomeValue"] = PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.EnumMember | PullElementKind.SomeFunction] = "SomeValue"; - PullElementKind[PullElementKind["SomeType"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Class | PullElementKind.Interface | PullElementKind.Enum | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.TypeParameter] = "SomeType"; + PullElementKind[PullElementKind["SomeType"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Class | PullElementKind.Interface | PullElementKind.Enum | PullElementKind.ObjectLiteral | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.TypeParameter] = "SomeType"; PullElementKind[PullElementKind["AcceptableAlias"] = PullElementKind.Variable | PullElementKind.SomeFunction | PullElementKind.Class | PullElementKind.Interface | PullElementKind.Enum | PullElementKind.Container | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "AcceptableAlias"; @@ -34800,17 +34942,18 @@ var TypeScript; })(TypeScript || (TypeScript = {})); var TypeScript; (function (TypeScript) { - TypeScript.pullDeclID = 0; + var pullDeclID = 0; var sentinelEmptyPullDeclArray = []; var PullDecl = (function () { - function PullDecl(declName, displayName, kind, declFlags, span) { - this.declID = TypeScript.pullDeclID++; + function PullDecl(declName, displayName, kind, declFlags, semanticInfoChain) { + this.declID = pullDeclID++; this.flags = 0 /* None */; this.declGroups = null; this.childDecls = null; this.typeParameters = null; this.synthesizedValDecl = null; + this.containerDecl = null; this.childDeclTypeCache = null; this.childDeclValueCache = null; this.childDeclNamespaceCache = null; @@ -34818,7 +34961,7 @@ var TypeScript; this.name = declName; this.kind = kind; this.flags = declFlags; - this.span = span; + this.semanticInfoChain = semanticInfoChain; if (displayName !== this.name) { this.declDisplayName = displayName; @@ -34836,10 +34979,6 @@ var TypeScript; throw TypeScript.Errors.abstract(); }; - PullDecl.prototype.semanticInfoChain = function () { - throw TypeScript.Errors.abstract(); - }; - PullDecl.prototype.isExternalModule = function () { throw TypeScript.Errors.abstract(); }; @@ -34872,44 +35011,42 @@ var TypeScript; }; PullDecl.prototype.setSymbol = function (symbol) { - this.semanticInfoChain().setSymbolForDecl(this, symbol); + this.semanticInfoChain.setSymbolForDecl(this, symbol); }; - PullDecl.prototype.ensureSymbolIsBound = function (bindSignatureSymbol) { - if (typeof bindSignatureSymbol === "undefined") { bindSignatureSymbol = false; } - if (!((bindSignatureSymbol && this.hasSignatureSymbol()) || this.hasSymbol()) && this.kind != 1 /* Script */) { - var binder = this.semanticInfoChain().getBinder(); + PullDecl.prototype.ensureSymbolIsBound = function () { + if (!this.hasBeenBound() && this.kind !== 1 /* Script */) { + var binder = this.semanticInfoChain.getBinder(); binder.bindDeclToPullSymbol(this); } }; PullDecl.prototype.getSymbol = function () { - if (this.kind == 1 /* Script */) { + if (this.kind === 1 /* Script */) { return null; } this.ensureSymbolIsBound(); - return this.semanticInfoChain().getSymbolForDecl(this); + return this.semanticInfoChain.getSymbolForDecl(this); }; PullDecl.prototype.hasSymbol = function () { - var symbol = this.semanticInfoChain().getSymbolForDecl(this); + var symbol = this.semanticInfoChain.getSymbolForDecl(this); return !!symbol; }; PullDecl.prototype.setSignatureSymbol = function (signatureSymbol) { - this.semanticInfoChain().setSignatureSymbolForDecl(this, signatureSymbol); + this.semanticInfoChain.setSignatureSymbolForDecl(this, signatureSymbol); }; PullDecl.prototype.getSignatureSymbol = function () { - this.ensureSymbolIsBound(true); - - return this.semanticInfoChain().getSignatureSymbolForDecl(this); + this.ensureSymbolIsBound(); + return this.semanticInfoChain.getSignatureSymbolForDecl(this); }; PullDecl.prototype.hasSignatureSymbol = function () { - var signatureSymbol = this.semanticInfoChain().getSignatureSymbolForDecl(this); + var signatureSymbol = this.semanticInfoChain.getSignatureSymbolForDecl(this); return !!signatureSymbol; }; @@ -34921,20 +35058,17 @@ var TypeScript; this.flags |= flags; }; - PullDecl.prototype.getSpan = function () { - return this.span; - }; - PullDecl.prototype.setValueDecl = function (valDecl) { this.synthesizedValDecl = valDecl; + valDecl.containerDecl = this; }; PullDecl.prototype.getValueDecl = function () { return this.synthesizedValDecl; }; - PullDecl.prototype.isEqual = function (other) { - return (this.name === other.name) && (this.kind === other.kind) && (this.flags === other.flags) && (this.fileName() === other.fileName()) && (this.span.start() === other.span.start()) && (this.span.end() === other.span.end()); + PullDecl.prototype.getContainerDecl = function () { + return this.containerDecl; }; PullDecl.prototype.getChildDeclCache = function (declKind) { @@ -34950,7 +35084,7 @@ var TypeScript; } return this.childDeclNamespaceCache; - } else if (TypeScript.hasFlag(declKind, 58728539 /* SomeType */)) { + } else if (TypeScript.hasFlag(declKind, 58728795 /* SomeType */)) { if (!this.childDeclTypeCache) { this.childDeclTypeCache = TypeScript.createIntrinsicsObject(); } @@ -34995,7 +35129,7 @@ var TypeScript; PullDecl.prototype.searchChildDecls = function (declName, searchKind) { var cacheVal = null; - if (searchKind & 58728539 /* SomeType */) { + if (searchKind & 58728795 /* SomeType */) { cacheVal = this.childDeclTypeCache ? this.childDeclTypeCache[declName] : null; } else if (searchKind & 164 /* SomeContainer */) { cacheVal = this.childDeclNamespaceCache ? this.childDeclNamespaceCache[declName] : null; @@ -35006,7 +35140,7 @@ var TypeScript; if (cacheVal) { return cacheVal; } else { - if (searchKind & 58728539 /* SomeType */) { + if (searchKind & 58728795 /* SomeType */) { cacheVal = this.childDeclTypeParameterCache ? this.childDeclTypeParameterCache[declName] : null; if (cacheVal) { @@ -35019,11 +35153,11 @@ var TypeScript; }; PullDecl.prototype.getChildDecls = function () { - return this.childDecls ? this.childDecls : sentinelEmptyPullDeclArray; + return this.childDecls || sentinelEmptyPullDeclArray; }; PullDecl.prototype.getTypeParameters = function () { - return this.typeParameters ? this.typeParameters : sentinelEmptyPullDeclArray; + return this.typeParameters || sentinelEmptyPullDeclArray; }; PullDecl.prototype.addVariableDeclToGroup = function (decl) { @@ -35056,7 +35190,7 @@ var TypeScript; } } - return declGroups ? declGroups : sentinelEmptyPullDeclArray; + return declGroups || sentinelEmptyPullDeclArray; }; PullDecl.prototype.hasBeenBound = function () { @@ -35068,8 +35202,11 @@ var TypeScript; }; PullDecl.prototype.ast = function () { - var semanticInfoChain = this.semanticInfoChain(); - return semanticInfoChain ? semanticInfoChain.getASTForDecl(this) : null; + return this.semanticInfoChain.getASTForDecl(this); + }; + + PullDecl.prototype.isRootDecl = function () { + throw TypeScript.Errors.abstract(); }; return PullDecl; })(); @@ -35077,9 +35214,9 @@ var TypeScript; var RootPullDecl = (function (_super) { __extends(RootPullDecl, _super); - function RootPullDecl(name, fileName, kind, declFlags, span, semanticInfoChain, isExternalModule) { - _super.call(this, name, name, kind, declFlags, span); - this._semanticInfoChain = semanticInfoChain; + function RootPullDecl(name, fileName, kind, declFlags, semanticInfoChain, isExternalModule) { + _super.call(this, name, name, kind, declFlags, semanticInfoChain); + this.semanticInfoChain = semanticInfoChain; this._isExternalModule = isExternalModule; this._fileName = fileName; } @@ -35095,10 +35232,6 @@ var TypeScript; return null; }; - RootPullDecl.prototype.semanticInfoChain = function () { - return this._semanticInfoChain; - }; - RootPullDecl.prototype.isExternalModule = function () { return this._isExternalModule; }; @@ -35106,15 +35239,18 @@ var TypeScript; RootPullDecl.prototype.getEnclosingDecl = function () { return this; }; + RootPullDecl.prototype.isRootDecl = function () { + return true; + }; return RootPullDecl; })(PullDecl); TypeScript.RootPullDecl = RootPullDecl; var NormalPullDecl = (function (_super) { __extends(NormalPullDecl, _super); - function NormalPullDecl(declName, displayName, kind, declFlags, parentDecl, span, addToParent) { + function NormalPullDecl(declName, displayName, kind, declFlags, parentDecl, addToParent) { if (typeof addToParent === "undefined") { addToParent = true; } - _super.call(this, declName, displayName, kind, declFlags, span); + _super.call(this, declName, displayName, kind, declFlags, parentDecl ? parentDecl.semanticInfoChain : null); this.parentDecl = null; this.parentPath = null; @@ -35122,9 +35258,20 @@ var TypeScript; if (addToParent) { parentDecl.addChildDecl(this); } + + if (this.parentDecl) { + if (this.parentDecl.isRootDecl()) { + this._rootDecl = this.parentDecl; + } else { + this._rootDecl = this.parentDecl._rootDecl; + } + } else { + TypeScript.Debug.assert(this.isSynthesized()); + this._rootDecl = null; + } } NormalPullDecl.prototype.fileName = function () { - return this.parentDecl ? this.parentDecl.fileName() : ""; + return this._rootDecl.fileName(); }; NormalPullDecl.prototype.getParentDecl = function () { @@ -35137,7 +35284,7 @@ var TypeScript; var parentDecl = this.parentDecl; while (parentDecl) { - if (parentDecl && path[path.length - 1] != parentDecl && !(parentDecl.kind & 256 /* ObjectLiteral */)) { + if (parentDecl && path[path.length - 1] !== parentDecl && !(parentDecl.kind & (256 /* ObjectLiteral */ | 8388608 /* ObjectType */))) { path.unshift(parentDecl); } @@ -35150,11 +35297,6 @@ var TypeScript; return this.parentPath; }; - NormalPullDecl.prototype.semanticInfoChain = function () { - var parent = this.getParentDecl(); - return parent ? parent.semanticInfoChain() : null; - }; - NormalPullDecl.prototype.isExternalModule = function () { return false; }; @@ -35162,14 +35304,18 @@ var TypeScript; NormalPullDecl.prototype.getEnclosingDecl = function () { return this.parentDecl && this.parentDecl._getEnclosingDeclFromParentDecl(); }; + + NormalPullDecl.prototype.isRootDecl = function () { + return false; + }; return NormalPullDecl; })(PullDecl); TypeScript.NormalPullDecl = NormalPullDecl; var PullEnumElementDecl = (function (_super) { __extends(PullEnumElementDecl, _super); - function PullEnumElementDecl(declName, displayName, parentDecl, span) { - _super.call(this, declName, displayName, 67108864 /* EnumMember */, 4 /* Public */, parentDecl, span); + function PullEnumElementDecl(declName, displayName, parentDecl) { + _super.call(this, declName, displayName, 67108864 /* EnumMember */, 4 /* Public */, parentDecl); this.constantValue = null; } return PullEnumElementDecl; @@ -35178,9 +35324,9 @@ var TypeScript; var PullFunctionExpressionDecl = (function (_super) { __extends(PullFunctionExpressionDecl, _super); - function PullFunctionExpressionDecl(expressionName, declFlags, parentDecl, span, displayName) { + function PullFunctionExpressionDecl(expressionName, declFlags, parentDecl, displayName) { if (typeof displayName === "undefined") { displayName = ""; } - _super.call(this, "", displayName, 131072 /* FunctionExpression */, declFlags, parentDecl, span); + _super.call(this, "", displayName, 131072 /* FunctionExpression */, declFlags, parentDecl); this.functionExpressionName = expressionName; } PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { @@ -35192,17 +35338,17 @@ var TypeScript; var PullSynthesizedDecl = (function (_super) { __extends(PullSynthesizedDecl, _super); - function PullSynthesizedDecl(declName, displayName, kind, declFlags, parentDecl, span, semanticInfoChain) { - _super.call(this, declName, displayName, kind, declFlags, parentDecl, span, false); - this._semanticInfoChain = semanticInfoChain; + function PullSynthesizedDecl(declName, displayName, kind, declFlags, parentDecl, semanticInfoChain) { + _super.call(this, declName, displayName, kind, declFlags, parentDecl, false); + this.semanticInfoChain = semanticInfoChain; } - PullSynthesizedDecl.prototype.semanticInfoChain = function () { - return this._semanticInfoChain; - }; - PullSynthesizedDecl.prototype.isSynthesized = function () { return true; }; + + PullSynthesizedDecl.prototype.fileName = function () { + return this._rootDecl ? this._rootDecl.fileName() : ""; + }; return PullSynthesizedDecl; })(NormalPullDecl); TypeScript.PullSynthesizedDecl = PullSynthesizedDecl; @@ -35228,12 +35374,11 @@ var TypeScript; var TypeScript; (function (TypeScript) { TypeScript.pullSymbolID = 0; - TypeScript.globalTyvarID = 0; TypeScript.sentinelEmptyArray = []; var PullSymbol = (function () { function PullSymbol(name, declKind) { - this.pullSymbolID = TypeScript.pullSymbolID++; + this.pullSymbolID = ++TypeScript.pullSymbolID; this._container = null; this.type = null; this._declarations = null; @@ -35254,7 +35399,7 @@ var TypeScript; }; PullSymbol.prototype.isType = function () { - return (this.kind & 58728539 /* SomeType */) != 0; + return (this.kind & 58728795 /* SomeType */) !== 0; }; PullSymbol.prototype.isTypeReference = function () { @@ -35262,7 +35407,7 @@ var TypeScript; }; PullSymbol.prototype.isSignature = function () { - return (this.kind & 7340032 /* SomeSignature */) != 0; + return (this.kind & 7340032 /* SomeSignature */) !== 0; }; PullSymbol.prototype.isArrayNamedTypeReference = function () { @@ -35323,7 +35468,7 @@ var TypeScript; return aliasSymbols; } - if (!skipScopeSymbolAliasesLookIn && this.isExternalModuleReferenceAlias(symbol) && (!symbol.assignedContainer().hasExportAssignment() || (symbol.assignedContainer().getExportAssignedContainerSymbol() && symbol.assignedContainer().getExportAssignedContainerSymbol().kind == 32 /* DynamicModule */))) { + if (!skipScopeSymbolAliasesLookIn && this.isExternalModuleReferenceAlias(symbol) && (!symbol.assignedContainer().hasExportAssignment() || (symbol.assignedContainer().getExportAssignedContainerSymbol() && symbol.assignedContainer().getExportAssignedContainerSymbol().kind === 32 /* DynamicModule */))) { scopeSymbolAliasesToLookIn.push(symbol); } } @@ -35366,11 +35511,11 @@ var TypeScript; return false; } - if (aliasSymbol.assignedType() && aliasSymbol.assignedType() != aliasSymbol.assignedContainer()) { + if (aliasSymbol.assignedType() && aliasSymbol.assignedType() !== aliasSymbol.assignedContainer()) { return false; } - if (aliasSymbol.assignedContainer() && aliasSymbol.assignedContainer().kind != 32 /* DynamicModule */) { + if (aliasSymbol.assignedContainer() && aliasSymbol.assignedContainer().kind !== 32 /* DynamicModule */) { return false; } @@ -35382,12 +35527,12 @@ var TypeScript; PullSymbol.prototype.getExportedInternalAliasSymbol = function (scopeSymbol) { if (scopeSymbol) { - if (this.kind != 128 /* TypeAlias */) { + if (this.kind !== 128 /* TypeAlias */) { var scopePath = scopeSymbol.pathToRoot(); for (var i = 0; i < scopePath.length; i++) { var internalAliases = this.findAliasedType(scopeSymbol, true, true); if (internalAliases) { - TypeScript.Debug.assert(internalAliases.length == 1); + TypeScript.Debug.assert(internalAliases.length === 1); return internalAliases[0]; } } @@ -35408,11 +35553,14 @@ var TypeScript; var externalAliases = this.getExternalAliasedSymbols(scopeSymbol); if (externalAliases && this.isExternalModuleReferenceAlias(externalAliases[externalAliases.length - 1])) { - var aliasFullName = ""; + var aliasFullName = aliasNameGetter(externalAliases[0]); + if (!aliasFullName) { + return null; + } for (var i = 1, symbolsLen = externalAliases.length; i < symbolsLen; i++) { aliasFullName = aliasFullName + "." + aliasPartsNameGetter(externalAliases[i]); } - return aliasNameGetter(externalAliases[0]) + aliasFullName; + return aliasFullName; } return null; @@ -35420,7 +35568,7 @@ var TypeScript; PullSymbol.prototype._getResolver = function () { TypeScript.Debug.assert(this._declarations && this._declarations.length > 0); - return this._declarations[0].semanticInfoChain().getResolver(); + return this._declarations[0].semanticInfoChain.getResolver(); }; PullSymbol.prototype._resolveDeclaredSymbol = function () { @@ -35433,11 +35581,7 @@ var TypeScript; }, function (symbol) { return symbol.getName(); }); - if (aliasName != null) { - return aliasName; - } - - return this.name; + return aliasName || this.name; }; PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { @@ -35446,7 +35590,7 @@ var TypeScript; }, function (symbol) { return symbol.getDisplayName(); }, skipInternalAliasName); - if (aliasDisplayName != null) { + if (aliasDisplayName) { return aliasDisplayName; } @@ -35472,10 +35616,14 @@ var TypeScript; PullSymbol.prototype.setIsSynthesized = function (value) { if (typeof value === "undefined") { value = true; } + TypeScript.Debug.assert(this.rootSymbol == null); this.isSynthesized = value; }; PullSymbol.prototype.getIsSynthesized = function () { + if (this.rootSymbol) { + return this.rootSymbol.getIsSynthesized(); + } return this.isSynthesized; }; @@ -35585,7 +35733,7 @@ var TypeScript; } path[path.length] = node; var nodeKind = node.kind; - if (nodeKind == 2048 /* Parameter */) { + if (nodeKind === 2048 /* Parameter */) { break; } else { node = node.getContainer(); @@ -35594,54 +35742,61 @@ var TypeScript; return path; }; - PullSymbol.prototype.findCommonAncestorPath = function (b) { - var aPath = this.pathToRoot(); - if (aPath.length === 1) { - return aPath; - } + PullSymbol.unqualifiedNameReferencesDifferentSymbolInScope = function (symbol, scopePath, endScopePathIndex) { + var declPath = scopePath[0].getDeclarations()[0].getParentPath(); + for (var i = 0, declIndex = declPath.length - 1; i <= endScopePathIndex; i++, declIndex--) { + if (symbol.isContainer() && scopePath[i].isContainer()) { + var scopeType = scopePath[i]; - var bPath; - if (b) { - bPath = b.pathToRoot(); - } else { - return aPath; - } + var memberSymbol = scopeType.findContainedNonMemberContainer(symbol.name, 164 /* SomeContainer */); + if (memberSymbol && memberSymbol != symbol && memberSymbol.getDeclarations()[0].getParentDecl() == declPath[declIndex]) { + return true; + } - var commonNodeIndex = -1; - for (var i = 0, aLen = aPath.length; i < aLen; i++) { - var aNode = aPath[i]; - for (var j = 0, bLen = bPath.length; j < bLen; j++) { - var bNode = bPath[j]; - if (aNode === bNode) { - var aDecl = null; - if (i > 0) { - var decls = aPath[i - 1].getDeclarations(); - if (decls.length) { - aDecl = decls[0].getParentDecl(); - } - } - var bDecl = null; - if (j > 0) { - var decls = bPath[j - 1].getDeclarations(); - if (decls.length) { - bDecl = decls[0].getParentDecl(); - } - } - if (!aDecl || !bDecl || aDecl == bDecl) { - commonNodeIndex = i; - break; - } + var memberSymbol = scopeType.findNestedContainer(symbol.name, 164 /* SomeContainer */); + if (memberSymbol && memberSymbol != symbol) { + return true; } } - if (commonNodeIndex >= 0) { - break; + } + + return false; + }; + + PullSymbol.prototype.findQualifyingSymbolPathInScopeSymbol = function (scopeSymbol) { + var thisPath = this.pathToRoot(); + if (thisPath.length === 1) { + return thisPath; + } + + var scopeSymbolPath; + if (scopeSymbol) { + scopeSymbolPath = scopeSymbol.pathToRoot(); + } else { + return thisPath; + } + + var thisCommonAncestorIndex = TypeScript.ArrayUtilities.indexOf(thisPath, function (thisNode) { + return TypeScript.ArrayUtilities.contains(scopeSymbolPath, thisNode); + }); + if (thisCommonAncestorIndex > 0) { + var thisCommonAncestor = thisPath[thisCommonAncestorIndex]; + var scopeCommonAncestorIndex = TypeScript.ArrayUtilities.indexOf(scopeSymbolPath, function (scopeNode) { + return scopeNode === thisCommonAncestor; + }); + TypeScript.Debug.assert(thisPath.length - thisCommonAncestorIndex === scopeSymbolPath.length - scopeCommonAncestorIndex); + + for (; thisCommonAncestorIndex < thisPath.length; thisCommonAncestorIndex++, scopeCommonAncestorIndex++) { + if (!PullSymbol.unqualifiedNameReferencesDifferentSymbolInScope(thisPath[thisCommonAncestorIndex - 1], scopeSymbolPath, scopeCommonAncestorIndex)) { + break; + } } } - if (commonNodeIndex >= 0) { - return aPath.slice(0, commonNodeIndex); + if (thisCommonAncestorIndex >= 0 && thisCommonAncestorIndex < thisPath.length) { + return thisPath.slice(0, thisCommonAncestorIndex); } else { - return aPath; + return thisPath; } }; @@ -35655,6 +35810,7 @@ var TypeScript; }; PullSymbol.prototype.fullName = function (scopeSymbol) { + var _this = this; var path = this.pathToRoot(); var fullName = ""; @@ -35663,23 +35819,23 @@ var TypeScript; }, function (symbol) { return symbol.getNamePartForFullName(); }); - if (aliasFullName != null) { + if (aliasFullName) { return aliasFullName; } for (var i = 1; i < path.length; i++) { var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.fullName(scopeSymbol); + return symbol === _this ? null : symbol.fullName(scopeSymbol); }, function (symbol) { return symbol.getNamePartForFullName(); }); - if (aliasFullName != null) { + if (aliasFullName) { fullName = aliasFullName + "." + fullName; break; } var scopedName = path[i].getNamePartForFullName(); - if (path[i].kind == 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { + if (path[i].kind === 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { break; } @@ -35695,7 +35851,7 @@ var TypeScript; }; PullSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { - var path = this.findCommonAncestorPath(scopeSymbol); + var path = this.findQualifyingSymbolPathInScopeSymbol(scopeSymbol); var fullName = ""; var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { @@ -35703,7 +35859,7 @@ var TypeScript; }, function (symbol) { return symbol.getNamePartForFullName(); }, skipInternalAliasName); - if (aliasFullName != null) { + if (aliasFullName) { return aliasFullName; } @@ -35715,7 +35871,7 @@ var TypeScript; }, function (symbol) { return symbol.getNamePartForFullName(); }, skipInternalAliasName); - if (aliasFullName != null) { + if (aliasFullName) { fullName = aliasFullName + "." + fullName; break; } @@ -35762,9 +35918,9 @@ var TypeScript; PullSymbol.prototype.getTypeNameForFunctionSignature = function (prefix, scopeSymbol, getPrettyTypeName) { var type = this.type; - if (type && !type.isNamedTypeSymbol() && this.kind != 4096 /* Property */ && this.kind != 512 /* Variable */ && this.kind != 2048 /* Parameter */) { + if (type && !type.isNamedTypeSymbol() && this.kind !== 4096 /* Property */ && this.kind !== 512 /* Variable */ && this.kind !== 2048 /* Parameter */) { var signatures = type.getCallSignatures(); - if (signatures.length == 1 || (getPrettyTypeName && signatures.length)) { + if (signatures.length === 1 || (getPrettyTypeName && signatures.length)) { var typeName = new TypeScript.MemberNameArray(); var signatureName = PullSignatureSymbol.getSignaturesTypeNameEx(signatures, prefix, false, false, scopeSymbol, getPrettyTypeName); typeName.addAll(signatureName); @@ -35881,7 +36037,7 @@ var TypeScript; var parentDecl = decls[0].getParentDecl(); if (parentDecl) { var parentSymbol = parentDecl.getSymbol(); - if (!parentSymbol || parentDecl.kind == 1 /* Script */) { + if (!parentSymbol || parentDecl.kind === 1 /* Script */) { return true; } @@ -35892,14 +36048,14 @@ var TypeScript; return true; } - if (container.kind == 32 /* DynamicModule */ || (container.getAssociatedContainerType() && container.getAssociatedContainerType().kind == 32 /* DynamicModule */)) { - var containerSymbol = container.kind == 32 /* DynamicModule */ ? container : container.getAssociatedContainerType(); + if (container.kind === 32 /* DynamicModule */ || (container.getAssociatedContainerType() && container.getAssociatedContainerType().kind === 32 /* DynamicModule */)) { + var containerSymbol = container.kind === 32 /* DynamicModule */ ? container : container.getAssociatedContainerType(); if (PullContainerSymbol.usedAsSymbol(containerSymbol, this)) { return true; } } - if (!this.anyDeclHasFlag(1 /* Exported */) && kind != 4096 /* Property */ && kind != 65536 /* Method */) { + if (!this.anyDeclHasFlag(1 /* Exported */) && kind !== 4096 /* Property */ && kind !== 65536 /* Method */) { return false; } @@ -35910,13 +36066,13 @@ var TypeScript; var ast = decl.ast(); if (ast) { - var enclosingModuleDeclaration = TypeScript.getEnclosingModuleDeclaration(ast); - if (TypeScript.isLastNameOfModule(enclosingModuleDeclaration, ast)) { - return TypeScript.docComments(enclosingModuleDeclaration); + var enclosingModuleDeclaration = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(ast); + if (TypeScript.ASTHelpers.isLastNameOfModule(enclosingModuleDeclaration, ast)) { + return TypeScript.ASTHelpers.docComments(enclosingModuleDeclaration); } - if (ast.kind() != 130 /* ModuleDeclaration */ || decl.kind != 512 /* Variable */) { - return TypeScript.docComments(ast); + if (ast.kind() !== 130 /* ModuleDeclaration */ || decl.kind !== 512 /* Variable */) { + return TypeScript.ASTHelpers.docComments(ast); } } @@ -35929,10 +36085,10 @@ var TypeScript; return docComments; } - var isParameter = symbol.kind == 2048 /* Parameter */; + var isParameter = symbol.kind === 2048 /* Parameter */; var decls = symbol.getDeclarations(); for (var i = 0; i < decls.length; i++) { - if (isParameter && decls[i].kind == 4096 /* Property */) { + if (isParameter && decls[i].kind === 4096 /* Property */) { continue; } docComments = docComments.concat(this.getDocCommentsOfDecl(decls[i])); @@ -35968,14 +36124,14 @@ var TypeScript; PullSymbol.prototype.docComments = function (useConstructorAsClass) { var decls = this.getDeclarations(); - if (useConstructorAsClass && decls.length && decls[0].kind == 32768 /* ConstructorMethod */) { + if (useConstructorAsClass && decls.length && decls[0].kind === 32768 /* ConstructorMethod */) { var classDecl = decls[0].getParentDecl(); return this.getDocCommentText(this.getDocCommentsOfDecl(classDecl)); } if (this._docComments === null) { var docComments = ""; - if (!useConstructorAsClass && this.kind == 2097152 /* ConstructSignature */ && decls.length && decls[0].kind == 8 /* Class */) { + if (!useConstructorAsClass && this.kind === 2097152 /* ConstructSignature */ && decls.length && decls[0].kind === 8 /* Class */) { var classSymbol = this.returnType; var extendedTypes = classSymbol.getExtendedTypes(); if (extendedTypes.length) { @@ -35983,7 +36139,7 @@ var TypeScript; } else { docComments = ""; } - } else if (this.kind == 2048 /* Parameter */) { + } else if (this.kind === 2048 /* Parameter */) { var parameterComments = []; var funcContainer = this.getEnclosingSignature(); @@ -36000,7 +36156,7 @@ var TypeScript; docComments = parameterComments.join("\n"); } else { var getSymbolComments = true; - if (this.kind == 16777216 /* FunctionType */) { + if (this.kind === 16777216 /* FunctionType */) { var functionSymbol = this.getFunctionSymbol(); if (functionSymbol) { @@ -36016,10 +36172,10 @@ var TypeScript; } if (getSymbolComments) { docComments = this.getDocCommentText(this.getDocCommentArray(this)); - if (docComments == "") { - if (this.kind == 1048576 /* CallSignature */) { + if (docComments === "") { + if (this.kind === 1048576 /* CallSignature */) { var callTypeSymbol = this.functionType; - if (callTypeSymbol && callTypeSymbol.getCallSignatures().length == 1) { + if (callTypeSymbol && callTypeSymbol.getCallSignatures().length === 1) { docComments = callTypeSymbol.docComments(); } } @@ -36230,34 +36386,41 @@ var TypeScript; })(); TypeScript.PullSymbol = PullSymbol; + + var PullSignatureSymbol = (function (_super) { __extends(PullSignatureSymbol, _super); - function PullSignatureSymbol(kind) { + function PullSignatureSymbol(kind, _isDefinition) { + if (typeof _isDefinition === "undefined") { _isDefinition = false; } _super.call(this, "", kind); + this._isDefinition = _isDefinition; this._memberTypeParameterNameCache = null; this._stringConstantOverload = undefined; this.parameters = TypeScript.sentinelEmptyArray; - this.typeParameters = null; + this._typeParameters = null; this.returnType = null; this.functionType = null; this.hasOptionalParam = false; this.nonOptionalParamCount = 0; this.hasVarArgs = false; - this.hasAGenericParameter = false; + this._allowedToReferenceTypeParameters = null; + this._instantiationCache = null; this.hasBeenChecked = false; this.inWrapCheck = false; + this.inWrapInfiniteExpandingReferenceCheck = false; } PullSignatureSymbol.prototype.isDefinition = function () { - return false; + return this._isDefinition; }; PullSignatureSymbol.prototype.isGeneric = function () { - return this.hasAGenericParameter || (this.typeParameters && this.typeParameters.length != 0); + var typeParameters = this.getTypeParameters(); + return !!typeParameters && typeParameters.length !== 0; }; PullSignatureSymbol.prototype.addParameter = function (parameter, isOptional) { if (typeof isOptional === "undefined") { isOptional = false; } - if (this.parameters == TypeScript.sentinelEmptyArray) { + if (this.parameters === TypeScript.sentinelEmptyArray) { this.parameters = []; } @@ -36274,25 +36437,32 @@ var TypeScript; }; PullSignatureSymbol.prototype.addTypeParameter = function (typeParameter) { - if (!this.typeParameters) { - this.typeParameters = []; + if (!this._typeParameters) { + this._typeParameters = []; } if (!this._memberTypeParameterNameCache) { this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); } - this.typeParameters[this.typeParameters.length] = typeParameter; + this._typeParameters[this._typeParameters.length] = typeParameter; this._memberTypeParameterNameCache[typeParameter.getName()] = typeParameter; }; + PullSignatureSymbol.prototype.addTypeParametersFromReturnType = function () { + var typeParameters = this.returnType.getTypeParameters(); + for (var i = 0; i < typeParameters.length; i++) { + this.addTypeParameter(typeParameters[i]); + } + }; + PullSignatureSymbol.prototype.getTypeParameters = function () { - if (!this.typeParameters) { - this.typeParameters = []; + if (!this._typeParameters) { + this._typeParameters = []; } - return this.typeParameters; + return this._typeParameters; }; PullSignatureSymbol.prototype.findTypeParameter = function (name) { @@ -36301,10 +36471,8 @@ var TypeScript; if (!this._memberTypeParameterNameCache) { this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); - if (this.typeParameters) { - for (var i = 0; i < this.typeParameters.length; i++) { - this._memberTypeParameterNameCache[this.typeParameters[i].getName()] = this.typeParameters[i]; - } + for (var i = 0; i < this.getTypeParameters().length; i++) { + this._memberTypeParameterNameCache[this._typeParameters[i].getName()] = this._typeParameters[i]; } } @@ -36313,6 +36481,38 @@ var TypeScript; return memberSymbol; }; + PullSignatureSymbol.prototype.getTypeParameterArgumentMap = function () { + return null; + }; + + PullSignatureSymbol.prototype.getAllowedToReferenceTypeParameters = function () { + TypeScript.Debug.assert(this.getRootSymbol() == this); + if (!this._allowedToReferenceTypeParameters) { + this._allowedToReferenceTypeParameters = TypeScript.PullInstantiationHelpers.getAllowedToReferenceTypeParametersFromDecl(this.getDeclarations()[0]); + } + + return this._allowedToReferenceTypeParameters; + }; + + PullSignatureSymbol.prototype.addSpecialization = function (specializedVersionOfThisSignature, typeArgumentMap) { + TypeScript.Debug.assert(this.getRootSymbol() == this); + if (!this._instantiationCache) { + this._instantiationCache = TypeScript.createIntrinsicsObject(); + } + + this._instantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)] = specializedVersionOfThisSignature; + }; + + PullSignatureSymbol.prototype.getSpecialization = function (typeArgumentMap) { + TypeScript.Debug.assert(this.getRootSymbol() == this); + if (!this._instantiationCache) { + return null; + } + + var result = this._instantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)]; + return result || null; + }; + PullSignatureSymbol.prototype.isStringConstantOverloadSignature = function () { if (this._stringConstantOverload === undefined) { var params = this.parameters; @@ -36328,6 +36528,20 @@ var TypeScript; return this._stringConstantOverload; }; + PullSignatureSymbol.prototype.getParameterTypeAtIndex = function (iParam) { + if (iParam < this.parameters.length - 1 || (iParam < this.parameters.length && !this.hasVarArgs)) { + return this.parameters[iParam].type; + } else if (this.hasVarArgs) { + var paramType = this.parameters[this.parameters.length - 1].type; + if (paramType.isArrayNamedTypeReference()) { + paramType = paramType.getElementType(); + } + return paramType; + } + + return null; + }; + PullSignatureSymbol.getSignatureTypeMemberName = function (candidateSignature, signatures, scopeSymbol) { var allMemberNames = new TypeScript.MemberNameArray(); var signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(signatures, "", false, false, scopeSymbol, true, candidateSignature); @@ -36455,75 +36669,110 @@ var TypeScript; return builder; }; + PullSignatureSymbol.prototype.forAllParameterTypes = function (length, predicate) { + if (this.parameters.length < length && !this.hasVarArgs) { + length = this.parameters.length; + } + + for (var i = 0; i < length; i++) { + var paramType = this.getParameterTypeAtIndex(i); + if (!predicate(paramType, i)) { + return false; + } + } + + return true; + }; + + PullSignatureSymbol.prototype.forAllCorrespondingParameterTypesInThisAndOtherSignature = function (otherSignature, predicate) { + var length; + if (this.hasVarArgs) { + length = otherSignature.hasVarArgs ? Math.max(this.parameters.length, otherSignature.parameters.length) : otherSignature.parameters.length; + } else { + length = otherSignature.hasVarArgs ? this.parameters.length : Math.min(this.parameters.length, otherSignature.parameters.length); + } + + for (var i = 0; i < length; i++) { + var thisParamType = this.getParameterTypeAtIndex(i); + var otherParamType = otherSignature.getParameterTypeAtIndex(i); + if (!predicate(thisParamType, otherParamType, i)) { + return false; + } + } + + return true; + }; + PullSignatureSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap) { + return this.getWrappingTypeParameterID(typeParameterArgumentMap) !== 0; + }; + + PullSignatureSymbol.prototype.getWrappingTypeParameterID = function (typeParameterArgumentMap) { var signature = this; if (signature.inWrapCheck) { - return false; + return 0; } + this._wrapsTypeParameterCache = this._wrapsTypeParameterCache || new TypeScript.WrapsTypeParameterCache(); + + var wrappingTypeParameterID = this._wrapsTypeParameterCache.getWrapsTypeParameter(typeParameterArgumentMap); + if (wrappingTypeParameterID === undefined) { + wrappingTypeParameterID = this.getWrappingTypeParameterIDWorker(typeParameterArgumentMap); + this._wrapsTypeParameterCache.setWrapsTypeParameter(typeParameterArgumentMap, wrappingTypeParameterID); + } + + return wrappingTypeParameterID; + }; + + PullSignatureSymbol.prototype.getWrappingTypeParameterIDWorker = function (typeParameterArgumentMap) { + var signature = this; signature.inWrapCheck = true; + TypeScript.PullHelpers.resolveDeclaredSymbolToUseType(signature); + var wrappingTypeParameterID = signature.returnType ? signature.returnType.getWrappingTypeParameterID(typeParameterArgumentMap) : 0; - var wrapsSomeTypeParameter = false; - - if (signature.returnType && signature.returnType.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - wrapsSomeTypeParameter = true; - } - - if (!wrapsSomeTypeParameter) { - var parameters = signature.parameters; - - for (var i = 0; i < parameters.length; i++) { - if (!parameters[i].type) { - parameters[i]._resolveDeclaredSymbol(); - } - - if (parameters[i].type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - wrapsSomeTypeParameter = true; - break; - } - } + var parameters = signature.parameters; + for (var i = 0; !wrappingTypeParameterID && i < parameters.length; i++) { + TypeScript.PullHelpers.resolveDeclaredSymbolToUseType(parameters[i]); + wrappingTypeParameterID = parameters[i].type.getWrappingTypeParameterID(typeParameterArgumentMap); } signature.inWrapCheck = false; - return wrapsSomeTypeParameter; + return wrappingTypeParameterID; }; - PullSignatureSymbol.prototype.wrapsSomeNestedTypeIntoInfiniteExpansion = function (typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap) { - if (this.inWrapCheck) { - return isCheckingTypeArgumentList; + PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference = function (enclosingType, knownWrapMap) { + var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); + if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { + return wrapsIntoInfinitelyExpandingTypeReference; } - if (knownWrapMap.valueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID) != undefined) { - return knownWrapMap.valueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID); + if (this.inWrapInfiniteExpandingReferenceCheck) { + return false; } - knownWrapMap.setValueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID, isCheckingTypeArgumentList); + this.inWrapInfiniteExpandingReferenceCheck = true; + wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); + knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); + this.inWrapInfiniteExpandingReferenceCheck = false; - this.inWrapCheck = true; + return wrapsIntoInfinitelyExpandingTypeReference; + }; - var wrapsSomeWrappedTypeParameter = false; - - if (this.returnType && this.returnType._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap)) { - wrapsSomeWrappedTypeParameter = true; + PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker = function (enclosingType, knownWrapMap) { + if (this.returnType && this.returnType._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; } - if (!wrapsSomeWrappedTypeParameter) { - var parameters = this.parameters; + var parameters = this.parameters; - for (var i = 0; i < parameters.length; i++) { - if (parameters[i].type && parameters[i].type._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap)) { - wrapsSomeWrappedTypeParameter = true; - break; - } + for (var i = 0; i < parameters.length; i++) { + if (parameters[i].type && parameters[i].type._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; } } - knownWrapMap.setValueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID, wrapsSomeWrappedTypeParameter); - - this.inWrapCheck = false; - - return wrapsSomeWrappedTypeParameter; + return false; }; return PullSignatureSymbol; })(PullSymbol); @@ -36537,6 +36786,7 @@ var TypeScript; this._enclosedMemberTypes = null; this._enclosedMemberContainers = null; this._typeParameters = null; + this._allowedToReferenceTypeParameters = null; this._specializedVersionsOfThisType = null; this._arrayVersionOfThisType = null; this._implementedTypes = null; @@ -36548,6 +36798,7 @@ var TypeScript; this._constructSignatures = null; this._indexSignatures = null; this._allIndexSignatures = null; + this._allIndexSignaturesOfAugmentedType = null; this._memberNameCache = null; this._enclosedTypeNameCache = null; this._enclosedContainerCache = null; @@ -36568,7 +36819,9 @@ var TypeScript; this._inMemberTypeNameEx = false; this.inSymbolPrivacyCheck = false; this.inWrapCheck = false; + this.inWrapInfiniteExpandingReferenceCheck = false; this.typeReference = null; + this._widenedType = null; this._isArrayNamedTypeReference = undefined; this.type = this; } @@ -36583,7 +36836,6 @@ var TypeScript; PullTypeSymbol.prototype.computeIsArrayNamedTypeReference = function () { var typeArgs = this.getTypeArguments(); if (typeArgs && this.getTypeArguments().length === 1 && this.name === "Array") { - var container = this.getContainer(); var declaration = this.getDeclarations()[0]; if (declaration && declaration.getParentDecl() && declaration.getParentDecl().getParentDecl() === null) { @@ -36598,13 +36850,13 @@ var TypeScript; return true; }; PullTypeSymbol.prototype.isClass = function () { - return this.kind == 8 /* Class */ || (this._constructorMethod != null); + return this.kind === 8 /* Class */ || (this._constructorMethod !== null); }; PullTypeSymbol.prototype.isFunction = function () { - return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) != 0; + return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) !== 0; }; PullTypeSymbol.prototype.isConstructor = function () { - return this.kind == 33554432 /* ConstructorType */; + return this.kind === 33554432 /* ConstructorType */; }; PullTypeSymbol.prototype.isTypeParameter = function () { return false; @@ -36616,7 +36868,7 @@ var TypeScript; return false; }; PullTypeSymbol.prototype.isEnum = function () { - return this.kind == 64 /* Enum */; + return this.kind === 64 /* Enum */; }; PullTypeSymbol.prototype.getTypeParameterArgumentMap = function () { @@ -36624,7 +36876,11 @@ var TypeScript; }; PullTypeSymbol.prototype.isObject = function () { - return TypeScript.hasFlag(this.kind, 8 /* Class */ | 33554432 /* ConstructorType */ | 64 /* Enum */ | 16777216 /* FunctionType */ | 16 /* Interface */ | 8388608 /* ObjectType */); + return TypeScript.hasFlag(this.kind, 8 /* Class */ | 33554432 /* ConstructorType */ | 64 /* Enum */ | 16777216 /* FunctionType */ | 16 /* Interface */ | 8388608 /* ObjectType */ | 256 /* ObjectLiteral */); + }; + + PullTypeSymbol.prototype.isFunctionType = function () { + return this.getCallSignatures().length > 0 || this.getConstructSignatures().length > 0; }; PullTypeSymbol.prototype.getKnownBaseTypeCount = function () { @@ -36645,7 +36901,7 @@ var TypeScript; }; PullTypeSymbol.prototype.hasMembers = function () { - if (this._members != TypeScript.sentinelEmptyArray) { + if (this._members !== TypeScript.sentinelEmptyArray) { return true; } @@ -36720,8 +36976,8 @@ var TypeScript; var nonMemberSymbol = this._containedNonMemberTypeNameCache[typeName]; - if (nonMemberSymbol && kind != 0 /* None */) { - nonMemberSymbol = ((nonMemberSymbol.kind & kind) != 0) ? nonMemberSymbol : null; + if (nonMemberSymbol && kind !== 0 /* None */) { + nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; } return nonMemberSymbol; @@ -36735,8 +36991,8 @@ var TypeScript; var nonMemberSymbol = this._containedNonMemberContainerCache[containerName]; - if (nonMemberSymbol && kind != 0 /* None */) { - nonMemberSymbol = ((nonMemberSymbol.kind & kind) != 0) ? nonMemberSymbol : null; + if (nonMemberSymbol && kind !== 0 /* None */) { + nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; } return nonMemberSymbol; @@ -36862,16 +37118,6 @@ var TypeScript; this._typeParameterNameCache[typeParameter.getName()] = typeParameter; }; - PullTypeSymbol.prototype.addConstructorTypeParameter = function (typeParameter) { - this.addTypeParameter(typeParameter); - - var constructSignatures = this.getConstructSignatures(); - - for (var i = 0; i < constructSignatures.length; i++) { - constructSignatures[i].addTypeParameter(typeParameter); - } - }; - PullTypeSymbol.prototype.getMembers = function () { return this._members; }; @@ -36901,31 +37147,52 @@ var TypeScript; return this._typeParameters; }; + PullTypeSymbol.prototype.getAllowedToReferenceTypeParameters = function () { + if (!!(this.kind && 8216 /* SomeInstantiatableType */) && this.isNamedTypeSymbol() && !this.isTypeParameter()) { + return this.getTypeParameters(); + } + + if (!this._allowedToReferenceTypeParameters) { + this._allowedToReferenceTypeParameters = TypeScript.PullInstantiationHelpers.getAllowedToReferenceTypeParametersFromDecl(this.getDeclarations()[0]); + } + + return this._allowedToReferenceTypeParameters; + }; + PullTypeSymbol.prototype.isGeneric = function () { return (this._typeParameters && this._typeParameters.length > 0) || this._hasGenericSignature || this._hasGenericMember || this.isArrayNamedTypeReference(); }; - PullTypeSymbol.prototype.canUseSimpleInstantiationCache = function (substitutingTypes) { - return substitutingTypes.length === 1 && substitutingTypes[0].kind !== 8388608 /* ObjectType */; - }; - - PullTypeSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { - if (!substitutingTypes || !substitutingTypes.length) { - return; + PullTypeSymbol.prototype.canUseSimpleInstantiationCache = function (typeArgumentMap) { + if (this.isTypeParameter()) { + return true; } - if (this.canUseSimpleInstantiationCache(substitutingTypes)) { + var typeParameters = this.getTypeParameters(); + return typeArgumentMap && this.isNamedTypeSymbol() && typeParameters.length === 1 && typeArgumentMap[typeParameters[0].pullSymbolID].kind !== 8388608 /* ObjectType */; + }; + + PullTypeSymbol.prototype.getSimpleInstantiationCacheId = function (typeArgumentMap) { + if (this.isTypeParameter()) { + return typeArgumentMap[0].pullSymbolID; + } + + return typeArgumentMap[this.getTypeParameters()[0].pullSymbolID].pullSymbolID; + }; + + PullTypeSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, typeArgumentMap) { + if (this.canUseSimpleInstantiationCache(typeArgumentMap)) { if (!this._simpleInstantiationCache) { this._simpleInstantiationCache = []; } - this._simpleInstantiationCache[substitutingTypes[0].pullSymbolID] = specializedVersionOfThisType; + this._simpleInstantiationCache[this.getSimpleInstantiationCacheId(typeArgumentMap)] = specializedVersionOfThisType; } else { if (!this._complexInstantiationCache) { this._complexInstantiationCache = TypeScript.createIntrinsicsObject(); } - this._complexInstantiationCache[getIDForTypeSubstitutions(substitutingTypes)] = specializedVersionOfThisType; + this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)] = specializedVersionOfThisType; } if (!this._specializedVersionsOfThisType) { @@ -36935,25 +37202,25 @@ var TypeScript; this._specializedVersionsOfThisType.push(specializedVersionOfThisType); }; - PullTypeSymbol.prototype.getSpecialization = function (substitutingTypes) { - if (!substitutingTypes || !substitutingTypes.length) { - return null; - } - - if (this.canUseSimpleInstantiationCache(substitutingTypes)) { + PullTypeSymbol.prototype.getSpecialization = function (typeArgumentMap) { + if (this.canUseSimpleInstantiationCache(typeArgumentMap)) { if (!this._simpleInstantiationCache) { return null; } - var result = this._simpleInstantiationCache[substitutingTypes[0].pullSymbolID]; - return result ? result : null; + var result = this._simpleInstantiationCache[this.getSimpleInstantiationCacheId(typeArgumentMap)]; + return result || null; } else { if (!this._complexInstantiationCache) { return null; } - var result = this._complexInstantiationCache[getIDForTypeSubstitutions(substitutingTypes)]; - return result ? result : null; + if (this.getAllowedToReferenceTypeParameters().length == 0) { + return this; + } + + var result = this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)]; + return result || null; } }; @@ -36973,13 +37240,11 @@ var TypeScript; return this.getTypeParameters(); }; - PullTypeSymbol.prototype.addCallSignature = function (callSignature) { + PullTypeSymbol.prototype.addCallSignaturePrerequisite = function (callSignature) { if (!this._callSignatures) { this._callSignatures = []; } - this._callSignatures[this._callSignatures.length] = callSignature; - if (callSignature.isGeneric()) { this._hasGenericSignature = true; } @@ -36987,13 +37252,26 @@ var TypeScript; callSignature.functionType = this; }; - PullTypeSymbol.prototype.addConstructSignature = function (constructSignature) { + PullTypeSymbol.prototype.appendCallSignature = function (callSignature) { + this.addCallSignaturePrerequisite(callSignature); + this._callSignatures.push(callSignature); + }; + + PullTypeSymbol.prototype.insertCallSignatureAtIndex = function (callSignature, index) { + this.addCallSignaturePrerequisite(callSignature); + TypeScript.Debug.assert(index <= this._callSignatures.length); + if (index === this._callSignatures.length) { + this._callSignatures.push(callSignature); + } else { + this._callSignatures.splice(index, 0, callSignature); + } + }; + + PullTypeSymbol.prototype.addConstructSignaturePrerequisite = function (constructSignature) { if (!this._constructSignatures) { this._constructSignatures = []; } - this._constructSignatures[this._constructSignatures.length] = constructSignature; - if (constructSignature.isGeneric()) { this._hasGenericSignature = true; } @@ -37001,6 +37279,21 @@ var TypeScript; constructSignature.functionType = this; }; + PullTypeSymbol.prototype.appendConstructSignature = function (constructSignature) { + this.addConstructSignaturePrerequisite(constructSignature); + this._constructSignatures.push(constructSignature); + }; + + PullTypeSymbol.prototype.insertConstructSignatureAtIndex = function (constructSignature, index) { + this.addConstructSignaturePrerequisite(constructSignature); + TypeScript.Debug.assert(index <= this._constructSignatures.length); + if (index === this._constructSignatures.length) { + this._constructSignatures.push(constructSignature); + } else { + this._constructSignatures.splice(index, 0, constructSignature); + } + }; + PullTypeSymbol.prototype.addIndexSignature = function (indexSignature) { if (!this._indexSignatures) { this._indexSignatures = []; @@ -37015,30 +37308,14 @@ var TypeScript; indexSignature.functionType = this; }; - PullTypeSymbol.prototype.addUnhiddenSignaturesFromBaseType = function (derivedTypeSignatures, baseTypeSignatures, signaturesBeingAggregated) { - if (!derivedTypeSignatures) { - signaturesBeingAggregated.push.apply(signaturesBeingAggregated, baseTypeSignatures); - return; - } - - var resolver = this._getResolver(); - for (var i = 0; i < baseTypeSignatures.length; i++) { - var baseSignature = baseTypeSignatures[i]; - - var signatureIsHidden = TypeScript.ArrayUtilities.any(derivedTypeSignatures, function (sig) { - return resolver.signaturesAreIdentical(baseSignature, sig, false); - }); - - if (!signatureIsHidden) { - signaturesBeingAggregated.push(baseSignature); - } - } - }; - PullTypeSymbol.prototype.hasOwnCallSignatures = function () { return this._callSignatures !== null; }; + PullTypeSymbol.prototype.getOwnCallSignatures = function () { + return this._callSignatures || TypeScript.sentinelEmptyArray; + }; + PullTypeSymbol.prototype.getCallSignatures = function () { if (this._allCallSignatures) { return this._allCallSignatures; @@ -37056,7 +37333,7 @@ var TypeScript; continue; } - this.addUnhiddenSignaturesFromBaseType(this._callSignatures, this._extendedTypes[i].getCallSignatures(), signatures); + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._callSignatures, this._extendedTypes[i].getCallSignatures(), signatures); } } @@ -37069,6 +37346,10 @@ var TypeScript; return this._constructSignatures !== null; }; + PullTypeSymbol.prototype.getOwnConstructSignatures = function () { + return this._constructSignatures || TypeScript.sentinelEmptyArray; + }; + PullTypeSymbol.prototype.getConstructSignatures = function () { var signatures = []; @@ -37082,7 +37363,7 @@ var TypeScript; continue; } - this.addUnhiddenSignaturesFromBaseType(this._constructSignatures, this._extendedTypes[i].getConstructSignatures(), signatures); + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._constructSignatures, this._extendedTypes[i].getConstructSignatures(), signatures); } } @@ -37114,7 +37395,7 @@ var TypeScript; continue; } - this.addUnhiddenSignaturesFromBaseType(this._indexSignatures, this._extendedTypes[i].getIndexSignatures(), signatures); + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._indexSignatures, this._extendedTypes[i].getIndexSignatures(), signatures); } } @@ -37123,6 +37404,45 @@ var TypeScript; return signatures; }; + PullTypeSymbol.prototype.getIndexSignaturesOfAugmentedType = function (resolver, globalFunctionInterface, globalObjectInterface) { + if (!this._allIndexSignaturesOfAugmentedType) { + var initialIndexSignatures = this.getIndexSignatures(); + var shouldAddFunctionSignatures = false; + var shouldAddObjectSignatures = false; + + if (globalFunctionInterface && this.isFunctionType() && this !== globalFunctionInterface) { + var functionIndexSignatures = globalFunctionInterface.getIndexSignatures(); + if (functionIndexSignatures.length) { + shouldAddFunctionSignatures = true; + } + } + + if (globalObjectInterface && this !== globalObjectInterface) { + var objectIndexSignatures = globalObjectInterface.getIndexSignatures(); + if (objectIndexSignatures.length) { + shouldAddObjectSignatures = true; + } + } + + if (shouldAddFunctionSignatures || shouldAddObjectSignatures) { + this._allIndexSignaturesOfAugmentedType = initialIndexSignatures.slice(0); + if (shouldAddFunctionSignatures) { + resolver._addUnhiddenSignaturesFromBaseType(initialIndexSignatures, functionIndexSignatures, this._allIndexSignaturesOfAugmentedType); + } + if (shouldAddObjectSignatures) { + if (shouldAddFunctionSignatures) { + initialIndexSignatures = initialIndexSignatures.concat(functionIndexSignatures); + } + resolver._addUnhiddenSignaturesFromBaseType(initialIndexSignatures, objectIndexSignatures, this._allIndexSignaturesOfAugmentedType); + } + } else { + this._allIndexSignaturesOfAugmentedType = initialIndexSignatures; + } + } + + return this._allIndexSignaturesOfAugmentedType; + }; + PullTypeSymbol.prototype.addImplementedType = function (implementedType) { if (!implementedType) { return; @@ -37293,8 +37613,8 @@ var TypeScript; memberSymbol = this._enclosedTypeNameCache[name]; - if (memberSymbol && kind != 0 /* None */) { - memberSymbol = ((memberSymbol.kind & kind) != 0) ? memberSymbol : null; + if (memberSymbol && kind !== 0 /* None */) { + memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; } return memberSymbol; @@ -37310,8 +37630,8 @@ var TypeScript; memberSymbol = this._enclosedContainerCache[name]; - if (memberSymbol && kind != 0 /* None */) { - memberSymbol = ((memberSymbol.kind & kind) != 0) ? memberSymbol : null; + if (memberSymbol && kind !== 0 /* None */) { + memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; } return memberSymbol; @@ -37320,7 +37640,7 @@ var TypeScript; PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { var allMembers = []; - if (this._members != TypeScript.sentinelEmptyArray) { + if (this._members !== TypeScript.sentinelEmptyArray) { for (var i = 0, n = this._members.length; i < n; i++) { var member = this._members[i]; if ((member.kind & searchDeclKind) && (memberVisiblity !== 2 /* externallyVisible */ || !member.anyDeclHasFlag(2 /* Private */))) { @@ -37386,7 +37706,7 @@ var TypeScript; PullTypeSymbol.prototype.isNamedTypeSymbol = function () { var kind = this.kind; - if (kind === 2 /* Primitive */ || kind === 8 /* Class */ || kind === 4 /* Container */ || kind === 32 /* DynamicModule */ || kind === 128 /* TypeAlias */ || kind === 64 /* Enum */ || kind === 8192 /* TypeParameter */ || ((kind === 16 /* Interface */ || kind === 8388608 /* ObjectType */) && this.name != "")) { + if (kind === 2 /* Primitive */ || kind === 8 /* Class */ || kind === 4 /* Container */ || kind === 32 /* DynamicModule */ || kind === 128 /* TypeAlias */ || kind === 64 /* Enum */ || kind === 8192 /* TypeParameter */ || ((kind === 16 /* Interface */ || kind === 8388608 /* ObjectType */) && this.name !== "")) { return true; } @@ -37398,8 +37718,9 @@ var TypeScript; return s; }; - PullTypeSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) { - if (this.isArrayNamedTypeReference()) { + PullTypeSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName, shouldAllowArrayType) { + if (typeof shouldAllowArrayType === "undefined") { shouldAllowArrayType = true; } + if (this.isArrayNamedTypeReference() && shouldAllowArrayType) { var elementType = this.getElementType(); var elementMemberName = elementType ? (elementType.isArrayNamedTypeReference() || elementType.isNamedTypeSymbol() ? elementType.getScopedNameEx(scopeSymbol, false, false, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) : elementType.getMemberTypeNameEx(false, scopeSymbol, getPrettyTypeName)) : TypeScript.MemberName.create("any"); return TypeScript.MemberName.create(elementMemberName, "", "[]"); @@ -37436,8 +37757,8 @@ var TypeScript; } var functionSymbol = this.getFunctionSymbol(); - if (functionSymbol && functionSymbol.kind == 16384 /* Function */ && !TypeScript.PullHelpers.isSymbolLocal(functionSymbol)) { - return functionSymbol; + if (functionSymbol && functionSymbol.kind === 16384 /* Function */ && !TypeScript.PullHelpers.isSymbolLocal(functionSymbol)) { + return TypeScript.PullHelpers.isExportedSymbolInClodule(functionSymbol) ? null : functionSymbol; } return null; @@ -37463,10 +37784,10 @@ var TypeScript; this._inMemberTypeNameEx = true; var allMemberNames = new TypeScript.MemberNameArray(); - var curlies = !topLevel || indexSignatures.length != 0; + var curlies = !topLevel || indexSignatures.length !== 0; var delim = "; "; for (var i = 0; i < members.length; i++) { - if (members[i].kind == 65536 /* Method */ && members[i].type.hasOnlyOverloadCallSignatures()) { + if (members[i].kind === 65536 /* Method */ && members[i].type.hasOnlyOverloadCallSignatures()) { var methodCallSignatures = members[i].type.getCallSignatures(); var nameStr = members[i].getDisplayName(scopeSymbol) + (members[i].isOptional ? "?" : ""); ; @@ -37524,32 +37845,55 @@ var TypeScript; return 2 /* Closed */; }; - PullTypeSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap) { + PullTypeSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap, skipTypeArgumentCheck) { + return this.getWrappingTypeParameterID(typeParameterArgumentMap, skipTypeArgumentCheck) != 0; + }; + + PullTypeSymbol.prototype.getWrappingTypeParameterID = function (typeParameterArgumentMap, skipTypeArgumentCheck) { var type = this; - var wrapsSomeTypeParameter = false; - if (type.isTypeParameter()) { - if (typeParameterArgumentMap[type.pullSymbolID]) { - return true; + if (typeParameterArgumentMap[type.pullSymbolID] || typeParameterArgumentMap[type.getRootSymbol().pullSymbolID]) { + return type.pullSymbolID; } var constraint = type.getConstraint(); - - if (constraint && constraint.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - return true; - } - - return false; + var wrappingTypeParameterID = constraint ? constraint.getWrappingTypeParameterID(typeParameterArgumentMap) : 0; + return wrappingTypeParameterID; } if (type.inWrapCheck) { - return wrapsSomeTypeParameter; + return 0; } - type.inWrapCheck = true; + this._wrapsTypeParameterCache = this._wrapsTypeParameterCache || new TypeScript.WrapsTypeParameterCache(); + var wrappingTypeParameterID = this._wrapsTypeParameterCache.getWrapsTypeParameter(typeParameterArgumentMap); + if (wrappingTypeParameterID === undefined) { + wrappingTypeParameterID = this.getWrappingTypeParameterIDWorker(typeParameterArgumentMap, skipTypeArgumentCheck); + + this._wrapsTypeParameterCache.setWrapsTypeParameter(typeParameterArgumentMap, wrappingTypeParameterID); + } + return wrappingTypeParameterID; + }; + + PullTypeSymbol.prototype.getWrappingTypeParameterIDFromSignatures = function (signatures, typeParameterArgumentMap) { + for (var i = 0; i < signatures.length; i++) { + var wrappingTypeParameterID = signatures[i].getWrappingTypeParameterID(typeParameterArgumentMap); + if (wrappingTypeParameterID !== 0) { + return wrappingTypeParameterID; + } + } + + return 0; + }; + + PullTypeSymbol.prototype.getWrappingTypeParameterIDWorker = function (typeParameterArgumentMap, skipTypeArgumentCheck) { + var type = this; + var wrappingTypeParameterID = 0; + + if (!skipTypeArgumentCheck) { + type.inWrapCheck = true; - if (!wrapsSomeTypeParameter) { var typeArguments = type.getTypeArguments(); if (type.isGeneric() && !typeArguments) { @@ -37557,217 +37901,131 @@ var TypeScript; } if (typeArguments) { - for (var i = 0; i < typeArguments.length; i++) { - if (typeArguments[i].wrapsSomeTypeParameter(typeParameterArgumentMap)) { - wrapsSomeTypeParameter = true; - break; - } + for (var i = 0; !wrappingTypeParameterID && i < typeArguments.length; i++) { + wrappingTypeParameterID = typeArguments[i].getWrappingTypeParameterID(typeParameterArgumentMap); } } } - if (!(type.kind & 8216 /* SomeInstantiatableType */) || !type.name) { - if (!wrapsSomeTypeParameter) { - var members = type.getAllMembers(68147712 /* SomeValue */, 0 /* all */); - - for (var i = 0; i < members.length; i++) { - if (members[i].type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - wrapsSomeTypeParameter = true; - break; - } - } + if (skipTypeArgumentCheck || !(type.kind & 8216 /* SomeInstantiatableType */) || !type.name) { + var members = type.getAllMembers(68147712 /* SomeValue */, 0 /* all */); + for (var i = 0; !wrappingTypeParameterID && i < members.length; i++) { + TypeScript.PullHelpers.resolveDeclaredSymbolToUseType(members[i]); + wrappingTypeParameterID = members[i].type.getWrappingTypeParameterID(typeParameterArgumentMap); } - if (!wrapsSomeTypeParameter) { - var sigs = type.getCallSignatures(); - - for (var i = 0; i < sigs.length; i++) { - if (sigs[i].wrapsSomeTypeParameter(typeParameterArgumentMap)) { - wrapsSomeTypeParameter = true; - break; - } - } - } - - if (!wrapsSomeTypeParameter) { - sigs = type.getConstructSignatures(); - - for (var i = 0; i < sigs.length; i++) { - if (sigs[i].wrapsSomeTypeParameter(typeParameterArgumentMap)) { - wrapsSomeTypeParameter = true; - break; - } - } - } - - if (!wrapsSomeTypeParameter) { - sigs = type.getIndexSignatures(); - - for (var i = 0; i < sigs.length; i++) { - if (sigs[i].wrapsSomeTypeParameter(typeParameterArgumentMap)) { - wrapsSomeTypeParameter = true; - break; - } - } - } + wrappingTypeParameterID = wrappingTypeParameterID || this.getWrappingTypeParameterIDFromSignatures(type.getCallSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getConstructSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getIndexSignatures(), typeParameterArgumentMap); } - type.inWrapCheck = false; + if (!skipTypeArgumentCheck) { + type.inWrapCheck = false; + } - return wrapsSomeTypeParameter; + return wrappingTypeParameterID; }; - PullTypeSymbol.prototype.wrapsSomeNestedTypeIntoInfiniteExpansion = function (typeBeingWrapped) { - if (!this.isArrayNamedTypeReference() && this.isNamedTypeSymbol()) { - var knownWrapMap = TypeScript.BitMatrix.getBitMatrix(true); - var result = this._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse(typeBeingWrapped, false, knownWrapMap); - knownWrapMap.release(); - - return result; - } - - return false; + PullTypeSymbol.prototype.wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference = function (enclosingType) { + TypeScript.Debug.assert(this.isNamedTypeSymbol()); + TypeScript.Debug.assert(TypeScript.PullHelpers.getRootType(enclosingType) == enclosingType); + var knownWrapMap = TypeScript.BitMatrix.getBitMatrix(true); + var wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap); + knownWrapMap.release(); + return wrapsIntoInfinitelyExpandingTypeReference; }; - PullTypeSymbol.prototype.isTypeEquivalentToRootSymbol = function () { - if (this.isTypeReference()) { - if (this.getIsSpecialized()) { - var typeArguments = this.getTypeArguments(); - var rootTypeArguments = this.getRootSymbol().getTypeArguments(); - if (typeArguments) { - for (var i = 0; i < typeArguments.length; i++) { - if (!typeArguments[i].isTypeParameter() && !(rootTypeArguments && rootTypeArguments[i] == typeArguments[i].getRootSymbol())) { - return false; - } - } - return true; - } - - return false; - } else { - return true; - } + PullTypeSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse = function (enclosingType, knownWrapMap) { + var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); + if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { + return wrapsIntoInfinitelyExpandingTypeReference; } - return false; - }; - - PullTypeSymbol.prototype.isTypeBeingWrapped = function (typeBeingWrapped) { - if (this.inWrapCheck || this == typeBeingWrapped) { - return true; - } - - if (typeBeingWrapped.isTypeEquivalentToRootSymbol()) { - return this.isTypeBeingWrapped(typeBeingWrapped.getRootSymbol()); - } - - return false; - }; - - PullTypeSymbol.prototype.anyRootTypeBeingWrapped = function (typeBeingWrapped) { - var prevRootType = this; - var rootType = this.getRootSymbol(); - while (rootType != prevRootType) { - if (rootType.isTypeBeingWrapped(typeBeingWrapped)) { - return true; - } - - prevRootType = rootType; - rootType = rootType.getRootSymbol(); - } - - return false; - }; - - PullTypeSymbol.prototype._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse = function (typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap) { - if (this.isArrayNamedTypeReference()) { - return this.getElementType()._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap); - } - - if (this.isTypeBeingWrapped(typeBeingWrapped)) { - return isCheckingTypeArgumentList; - } - - if (knownWrapMap.valueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID) != undefined) { - return knownWrapMap.valueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID); - } - - if (this.isPrimitive() || this.isTypeParameter()) { + if (this.inWrapInfiniteExpandingReferenceCheck) { return false; } - this.inWrapCheck = true; + this.inWrapInfiniteExpandingReferenceCheck = true; + wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); + knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); + this.inWrapInfiniteExpandingReferenceCheck = false; - var wrapsSomeWrappedTypeParameter = false; - - knownWrapMap.setValueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID, false); - - wrapsSomeWrappedTypeParameter = this._wrapsSomeNestedTypeIntoInfiniteExpansionWorker(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap); - - knownWrapMap.setValueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID, wrapsSomeWrappedTypeParameter); - - this.inWrapCheck = false; - - return wrapsSomeWrappedTypeParameter; + return wrapsIntoInfinitelyExpandingTypeReference; }; - PullTypeSymbol.prototype._wrapsSomeNestedTypeIntoInfiniteExpansionWorker = function (typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap) { + PullTypeSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker = function (enclosingType, knownWrapMap) { + var thisRootType = TypeScript.PullHelpers.getRootType(this); + + if (thisRootType != enclosingType) { + var thisIsNamedType = this.isNamedTypeSymbol(); + + if (thisIsNamedType) { + if (thisRootType.inWrapInfiniteExpandingReferenceCheck) { + return false; + } + + thisRootType.inWrapInfiniteExpandingReferenceCheck = true; + } + + var wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceStructure(enclosingType, knownWrapMap); + + if (thisIsNamedType) { + thisRootType.inWrapInfiniteExpandingReferenceCheck = false; + } + + return wrapsIntoInfinitelyExpandingTypeReference; + } + + var enclosingTypeParameters = enclosingType.getTypeParameters(); var typeArguments = this.getTypeArguments(); - if (typeArguments) { - for (var i = 0; i < typeArguments.length; i++) { - if (typeArguments[i]._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse(typeBeingWrapped, true, knownWrapMap)) { - return true; - } + for (var i = 0; i < typeArguments.length; i++) { + if (TypeScript.ArrayUtilities.contains(enclosingTypeParameters, typeArguments[i])) { + continue; } - } - if (this.anyRootTypeBeingWrapped(typeBeingWrapped)) { - if (isCheckingTypeArgumentList && this.isTypeReference() && !this.getIsSpecialized()) { + if (typeArguments[i].wrapsSomeTypeParameter(this.getTypeParameterArgumentMap())) { return true; } - - return false; - } else if (!this.isNamedTypeSymbol() || this.isGeneric()) { - var isTypeEquivalentToRootSymbol = this.isTypeEquivalentToRootSymbol(); - var rootType = TypeScript.PullHelpers.getRootType(this); - if (isTypeEquivalentToRootSymbol) { - rootType.inWrapCheck = true; - } - - var members = this.getAllMembers(68147712 /* SomeValue */, 0 /* all */); - for (var i = 0; i < members.length; i++) { - if (members[i].type && members[i].type._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap)) { - return true; - } - } - - var sigs = this.getCallSignatures(); - for (var i = 0; i < sigs.length; i++) { - if (sigs[i].wrapsSomeNestedTypeIntoInfiniteExpansion(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap)) { - return true; - } - } - - sigs = this.getConstructSignatures(); - for (var i = 0; i < sigs.length; i++) { - if (sigs[i].wrapsSomeNestedTypeIntoInfiniteExpansion(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap)) { - return true; - } - } - - sigs = this.getIndexSignatures(); - for (var i = 0; i < sigs.length; i++) { - if (sigs[i].wrapsSomeNestedTypeIntoInfiniteExpansion(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap)) { - return true; - } - } - - if (isTypeEquivalentToRootSymbol) { - rootType.inWrapCheck = false; - } - - return false; } + + return false; + }; + + PullTypeSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceStructure = function (enclosingType, knownWrapMap) { + var members = this.getAllMembers(68147712 /* SomeValue */, 0 /* all */); + for (var i = 0; i < members.length; i++) { + if (members[i].type && members[i].type._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; + } + } + + var sigs = this.getCallSignatures(); + for (var i = 0; i < sigs.length; i++) { + if (sigs[i]._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference(enclosingType, knownWrapMap)) { + return true; + } + } + + sigs = this.getConstructSignatures(); + for (var i = 0; i < sigs.length; i++) { + if (sigs[i]._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference(enclosingType, knownWrapMap)) { + return true; + } + } + + sigs = this.getIndexSignatures(); + for (var i = 0; i < sigs.length; i++) { + if (sigs[i]._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference(enclosingType, knownWrapMap)) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.widenedType = function (resolver, ast, context) { + if (!this._widenedType) { + this._widenedType = resolver.widenType(this, ast, context); + } + return this._widenedType; }; return PullTypeSymbol; })(PullSymbol); @@ -37781,7 +38039,15 @@ var TypeScript; this.isResolved = true; } PullPrimitiveTypeSymbol.prototype.isAny = function () { - return this.name === "any"; + return !this.isStringConstant() && this.name === "any"; + }; + + PullPrimitiveTypeSymbol.prototype.isNull = function () { + return !this.isStringConstant() && this.name === "null"; + }; + + PullPrimitiveTypeSymbol.prototype.isUndefined = function () { + return !this.isStringConstant() && this.name === "undefined"; }; PullPrimitiveTypeSymbol.prototype.isStringConstant = function () { @@ -37790,6 +38056,14 @@ var TypeScript; PullPrimitiveTypeSymbol.prototype.setUnresolved = function () { }; + + PullPrimitiveTypeSymbol.prototype.getDisplayName = function () { + if (this.isNull() || this.isUndefined()) { + return "any"; + } else { + return _super.prototype.getDisplayName.call(this); + } + }; return PullPrimitiveTypeSymbol; })(PullTypeSymbol); TypeScript.PullPrimitiveTypeSymbol = PullPrimitiveTypeSymbol; @@ -37808,26 +38082,31 @@ var TypeScript; var PullErrorTypeSymbol = (function (_super) { __extends(PullErrorTypeSymbol, _super); - function PullErrorTypeSymbol(anyType, name) { + function PullErrorTypeSymbol(_anyType, name) { _super.call(this, name); - this.anyType = anyType; + this._anyType = _anyType; + TypeScript.Debug.assert(this._anyType); this.isResolved = true; } PullErrorTypeSymbol.prototype.isError = function () { return true; }; + PullErrorTypeSymbol.prototype._getResolver = function () { + return this._anyType._getResolver(); + }; + PullErrorTypeSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - return this.anyType.getName(scopeSymbol, useConstraintInName); + return this._anyType.getName(scopeSymbol, useConstraintInName); }; PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - return this.anyType.getName(scopeSymbol, useConstraintInName); + return this._anyType.getName(scopeSymbol, useConstraintInName); }; PullErrorTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - return this.anyType.getName(scopeSymbol, useConstraintInName); + return this._anyType.getName(scopeSymbol, useConstraintInName); }; return PullErrorTypeSymbol; })(PullPrimitiveTypeSymbol); @@ -37887,7 +38166,7 @@ var TypeScript; return false; } - if (!containerSymbol.isAlias() && containerSymbol.type == symbol) { + if (!containerSymbol.isAlias() && containerSymbol.type === symbol) { return true; } @@ -37896,7 +38175,7 @@ var TypeScript; var typeExportSymbol = moduleSymbol.getExportAssignedTypeSymbol(); var containerExportSymbol = moduleSymbol.getExportAssignedContainerSymbol(); if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { - return valueExportSymbol == symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerSymbol.usedAsSymbol(containerExportSymbol, symbol); + return valueExportSymbol === symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerSymbol.usedAsSymbol(containerExportSymbol, symbol); } return false; @@ -37918,8 +38197,15 @@ var TypeScript; this._assignedContainer = null; this._isUsedAsValue = false; this._typeUsedExternally = false; + this._isUsedInExportAlias = false; this.retrievingExportAssignment = false; + this.linkedAliasSymbols = null; } + PullTypeAliasSymbol.prototype.isUsedInExportedAlias = function () { + this._resolveDeclaredSymbol(); + return this._isUsedInExportAlias; + }; + PullTypeAliasSymbol.prototype.typeUsedExternally = function () { this._resolveDeclaredSymbol(); return this._typeUsedExternally; @@ -37930,19 +38216,33 @@ var TypeScript; return this._isUsedAsValue; }; - PullTypeAliasSymbol.prototype.setTypeUsedExternally = function (value) { - this._typeUsedExternally = value; + PullTypeAliasSymbol.prototype.setTypeUsedExternally = function () { + this._typeUsedExternally = true; }; - PullTypeAliasSymbol.prototype.setIsUsedAsValue = function (value) { - this._isUsedAsValue = value; + PullTypeAliasSymbol.prototype.setIsUsedInExportedAlias = function () { + this._isUsedInExportAlias = true; + if (this.linkedAliasSymbols) { + this.linkedAliasSymbols.forEach(function (s) { + return s.setIsUsedInExportedAlias(); + }); + } + }; - this._resolveDeclaredSymbol(); - var resolver = this._getResolver(); - var importDeclStatement = resolver.semanticInfoChain.getASTForDecl(this.getDeclarations()[0]); - var aliasSymbol = resolver.semanticInfoChain.getAliasSymbolForAST(importDeclStatement.moduleReference); - if (aliasSymbol) { - aliasSymbol.setIsUsedAsValue(value); + PullTypeAliasSymbol.prototype.addLinkedAliasSymbol = function (contingentValueSymbol) { + if (!this.linkedAliasSymbols) { + this.linkedAliasSymbols = [contingentValueSymbol]; + } else { + this.linkedAliasSymbols.push(contingentValueSymbol); + } + }; + + PullTypeAliasSymbol.prototype.setIsUsedAsValue = function () { + this._isUsedAsValue = true; + if (this.linkedAliasSymbols) { + this.linkedAliasSymbols.forEach(function (s) { + return s.setIsUsedAsValue(); + }); } }; @@ -38005,7 +38305,7 @@ var TypeScript; this.retrievingExportAssignment = true; var sym = this._assignedType.getExportAssignedTypeSymbol(); this.retrievingExportAssignment = false; - } else if (this._assignedType != this._assignedContainer) { + } else if (this._assignedType !== this._assignedContainer) { return this._assignedType; } } @@ -38110,31 +38410,15 @@ var TypeScript; })(PullTypeSymbol); TypeScript.PullTypeAliasSymbol = PullTypeAliasSymbol; - var PullDefinitionSignatureSymbol = (function (_super) { - __extends(PullDefinitionSignatureSymbol, _super); - function PullDefinitionSignatureSymbol() { - _super.apply(this, arguments); - } - PullDefinitionSignatureSymbol.prototype.isDefinition = function () { - return true; - }; - return PullDefinitionSignatureSymbol; - })(PullSignatureSymbol); - TypeScript.PullDefinitionSignatureSymbol = PullDefinitionSignatureSymbol; - var PullTypeParameterSymbol = (function (_super) { __extends(PullTypeParameterSymbol, _super); - function PullTypeParameterSymbol(name, _isFunctionTypeParameter) { + function PullTypeParameterSymbol(name) { _super.call(this, name, 8192 /* TypeParameter */); - this._isFunctionTypeParameter = _isFunctionTypeParameter; this._constraint = null; } PullTypeParameterSymbol.prototype.isTypeParameter = function () { return true; }; - PullTypeParameterSymbol.prototype.isFunctionTypeParameter = function () { - return this._isFunctionTypeParameter; - }; PullTypeParameterSymbol.prototype.setConstraint = function (constraintType) { this._constraint = constraintType; @@ -38144,6 +38428,34 @@ var TypeScript; return this._constraint; }; + PullTypeParameterSymbol.prototype.getBaseConstraint = function (semanticInfoChain) { + var preBaseConstraint = this.getConstraintRecursively({}); + TypeScript.Debug.assert(preBaseConstraint === null || !preBaseConstraint.isTypeParameter()); + return preBaseConstraint || semanticInfoChain.emptyTypeSymbol; + }; + + PullTypeParameterSymbol.prototype.getConstraintRecursively = function (visitedTypeParameters) { + var constraint = this.getConstraint(); + + if (constraint) { + if (constraint.isTypeParameter()) { + var constraintAsTypeParameter = constraint; + if (!visitedTypeParameters[constraintAsTypeParameter.pullSymbolID]) { + visitedTypeParameters[constraintAsTypeParameter.pullSymbolID] = constraintAsTypeParameter; + return constraintAsTypeParameter.getConstraintRecursively(visitedTypeParameters); + } + } else { + return constraint; + } + } + + return null; + }; + + PullTypeParameterSymbol.prototype.getDefaultConstraint = function (semanticInfoChain) { + return this._constraint || semanticInfoChain.emptyTypeSymbol; + }; + PullTypeParameterSymbol.prototype.getCallSignatures = function () { if (this._constraint) { return this._constraint.getCallSignatures(); @@ -38264,80 +38576,79 @@ var TypeScript; })(PullSymbol); TypeScript.PullAccessorSymbol = PullAccessorSymbol; - function getIDForTypeSubstitutions(types) { + function getIDForTypeSubstitutions(instantiatingTypeOrSignature, typeArgumentMap) { var substitution = ""; var members = null; - for (var i = 0; i < types.length; i++) { - if (types[i].kind !== 8388608 /* ObjectType */) { - substitution += types[i].pullSymbolID + "#"; - } else { - var structure = getIDForTypeSubstitutionsFromObjectType(types[i]); - - if (structure) { - substitution += structure; - } else { - substitution += types[i].pullSymbolID + "#"; - } + var allowedToReferenceTypeParameters = instantiatingTypeOrSignature.getAllowedToReferenceTypeParameters(); + for (var i = 0; i < allowedToReferenceTypeParameters.length; i++) { + var typeParameter = allowedToReferenceTypeParameters[i]; + var typeParameterID = typeParameter.pullSymbolID; + var typeArg = typeArgumentMap[typeParameterID]; + if (!typeArg) { + typeArg = typeParameter; } + substitution += typeParameterID + ":" + getIDForTypeSubstitutionsOfType(typeArg); } return substitution; } TypeScript.getIDForTypeSubstitutions = getIDForTypeSubstitutions; - function getIDForTypeSubstitutionsFromObjectType(type) { - var structure = ""; - - if (type.isResolved) { - var members = type.getMembers(); - if (members && members.length) { - for (var j = 0; j < members.length; j++) { - structure += members[j].name + "@" + getIDForTypeSubstitutions([members[j].type]); - } - } - - var callSignatures = type.getCallSignatures(); - if (callSignatures && callSignatures.length) { - for (var j = 0; j < callSignatures.length; j++) { - structure += getIDForTypeSubstitutionFromSignature(callSignatures[j]); - } - } - - var constructSignatures = type.getConstructSignatures(); - if (constructSignatures && constructSignatures.length) { - for (var j = 0; j < constructSignatures.length; j++) { - structure += "new" + getIDForTypeSubstitutionFromSignature(constructSignatures[j]); - } - } - - var indexSignatures = type.getIndexSignatures(); - if (indexSignatures && indexSignatures.length) { - for (var j = 0; j < indexSignatures.length; j++) { - structure += "[]" + getIDForTypeSubstitutionFromSignature(indexSignatures[j]); - } - } + function getIDForTypeSubstitutionsOfType(type) { + var structure; + if (type.isError()) { + structure = "E" + getIDForTypeSubstitutionsOfType(type._anyType); + } else if (!type.isNamedTypeSymbol()) { + structure = getIDForTypeSubstitutionsFromObjectType(type); } - if (structure !== "") { - return "{" + structure + "}"; + if (!structure) { + structure = type.pullSymbolID + "#"; + } + + return structure; + } + + function getIDForTypeSubstitutionsFromObjectType(type) { + if (type.isResolved) { + var getIDForTypeSubStitutionWalker = new GetIDForTypeSubStitutionWalker(); + TypeScript.PullHelpers.walkPullTypeSymbolStructure(type, getIDForTypeSubStitutionWalker); } return null; } - function getIDForTypeSubstitutionFromSignature(signature) { - var structure = "("; - var parameters = signature.parameters; - if (parameters && parameters.length) { - for (var k = 0; k < parameters.length; k++) { - structure += parameters[k].name + "@" + getIDForTypeSubstitutions([parameters[k].type]); - } + var GetIDForTypeSubStitutionWalker = (function () { + function GetIDForTypeSubStitutionWalker() { + this.structure = ""; } - - structure += ")" + getIDForTypeSubstitutions([signature.returnType]); - return structure; - } + GetIDForTypeSubStitutionWalker.prototype.memberSymbolWalk = function (memberSymbol) { + this.structure += memberSymbol.name + "@" + getIDForTypeSubstitutionsOfType(memberSymbol.type); + return true; + }; + GetIDForTypeSubStitutionWalker.prototype.callSignatureWalk = function (signatureSymbol) { + this.structure += "("; + return true; + }; + GetIDForTypeSubStitutionWalker.prototype.constructSignatureWalk = function (signatureSymbol) { + this.structure += "new("; + return true; + }; + GetIDForTypeSubStitutionWalker.prototype.indexSignatureWalk = function (signatureSymbol) { + this.structure += "[]("; + return true; + }; + GetIDForTypeSubStitutionWalker.prototype.signatureParameterWalk = function (parameterSymbol) { + this.structure += parameterSymbol.name + "@" + getIDForTypeSubstitutionsOfType(parameterSymbol.type); + return true; + }; + GetIDForTypeSubStitutionWalker.prototype.signatureReturnTypeWalk = function (returnType) { + this.structure += ")" + getIDForTypeSubstitutionsOfType(returnType); + return true; + }; + return GetIDForTypeSubStitutionWalker; + })(); (function (GetAllMembersVisiblity) { GetAllMembersVisiblity[GetAllMembersVisiblity["all"] = 0] = "all"; @@ -38349,38 +38660,311 @@ var TypeScript; var GetAllMembersVisiblity = TypeScript.GetAllMembersVisiblity; })(TypeScript || (TypeScript = {})); var TypeScript; +(function (TypeScript) { + var PullTypeEnclosingTypeWalker = (function () { + function PullTypeEnclosingTypeWalker() { + this.currentSymbols = null; + } + PullTypeEnclosingTypeWalker.prototype.getEnclosingType = function () { + if (this.currentSymbols && this.currentSymbols.length > 0) { + return this.currentSymbols[0]; + } + + return null; + }; + + PullTypeEnclosingTypeWalker.prototype._canWalkStructure = function () { + var enclosingType = this.getEnclosingType(); + return !!enclosingType && enclosingType.isGeneric(); + }; + + PullTypeEnclosingTypeWalker.prototype._getCurrentSymbol = function () { + if (this.currentSymbols && this.currentSymbols.length) { + return this.currentSymbols[this.currentSymbols.length - 1]; + } + + return null; + }; + + PullTypeEnclosingTypeWalker.prototype.getGenerativeClassification = function () { + if (this._canWalkStructure()) { + var currentType = this.currentSymbols[this.currentSymbols.length - 1]; + if (!currentType) { + return 0 /* Unknown */; + } + + var variableNeededToFixNodeJitterBug = this.getEnclosingType(); + + return currentType.getGenerativeTypeClassification(variableNeededToFixNodeJitterBug); + } + + return 2 /* Closed */; + }; + + PullTypeEnclosingTypeWalker.prototype._pushSymbol = function (symbol) { + return this.currentSymbols.push(symbol); + }; + + PullTypeEnclosingTypeWalker.prototype._popSymbol = function () { + return this.currentSymbols.pop(); + }; + + PullTypeEnclosingTypeWalker.prototype._setEnclosingTypeOfParentDecl = function (decl, setSignature) { + var parentDecl = decl.getParentDecl(); + if (parentDecl) { + if (parentDecl.kind & 8216 /* SomeInstantiatableType */) { + this._setEnclosingTypeWorker(parentDecl.getSymbol(), true); + } else { + this._setEnclosingTypeOfParentDecl(parentDecl, true); + } + + if (this._canWalkStructure()) { + var symbol = decl.getSymbol(); + if (symbol) { + if (symbol.kind == 2048 /* Parameter */ || symbol.kind == 4096 /* Property */ || symbol.kind == 65536 /* Method */ || symbol.kind == 32768 /* ConstructorMethod */ || symbol.kind == 131072 /* FunctionExpression */) { + symbol = symbol.type; + } + + this._pushSymbol(symbol); + } + + if (setSignature) { + var signature = decl.getSignatureSymbol(); + if (signature) { + this._pushSymbol(signature); + } + } + } + } + }; + + PullTypeEnclosingTypeWalker.prototype._setEnclosingTypeWorker = function (symbol, setSignature) { + if (symbol.isType() && symbol.isNamedTypeSymbol()) { + this.currentSymbols = [TypeScript.PullHelpers.getRootType(symbol)]; + return; + } + + var decls = symbol.getDeclarations(); + for (var i = 0; i < decls.length; i++) { + var decl = decls[i]; + this._setEnclosingTypeOfParentDecl(decl, setSignature); + if (this._canWalkStructure()) { + return; + } + } + }; + + PullTypeEnclosingTypeWalker.prototype.setCurrentSymbol = function (symbol) { + TypeScript.Debug.assert(this._canWalkStructure()); + this.currentSymbols[this.currentSymbols.length - 1] = symbol; + }; + + PullTypeEnclosingTypeWalker.prototype.startWalkingType = function (symbol) { + var currentSymbols = this.currentSymbols; + + var setEnclosingType = !this.getEnclosingType() || symbol.isNamedTypeSymbol(); + if (setEnclosingType) { + this.currentSymbols = null; + this.setEnclosingType(symbol); + } + return currentSymbols; + }; + + PullTypeEnclosingTypeWalker.prototype.endWalkingType = function (currentSymbolsWhenStartedWalkingTypes) { + this.currentSymbols = currentSymbolsWhenStartedWalkingTypes; + }; + + PullTypeEnclosingTypeWalker.prototype.setEnclosingType = function (symbol) { + TypeScript.Debug.assert(!this.getEnclosingType()); + this._setEnclosingTypeWorker(symbol, symbol.isSignature()); + }; + + PullTypeEnclosingTypeWalker.prototype.walkMemberType = function (memberName, resolver) { + if (this._canWalkStructure()) { + var currentType = this._getCurrentSymbol(); + var memberSymbol = currentType ? resolver._getNamedPropertySymbolOfAugmentedType(memberName, currentType) : null; + this._pushSymbol(memberSymbol ? memberSymbol.type : null); + } + }; + + PullTypeEnclosingTypeWalker.prototype.postWalkMemberType = function () { + if (this._canWalkStructure()) { + this._popSymbol(); + } + }; + + PullTypeEnclosingTypeWalker.prototype.walkSignature = function (kind, index) { + if (this._canWalkStructure()) { + var currentType = this._getCurrentSymbol(); + var signatures; + if (currentType) { + if (kind == 1048576 /* CallSignature */) { + signatures = currentType.getCallSignatures(); + } else if (kind == 2097152 /* ConstructSignature */) { + signatures = currentType.getConstructSignatures(); + } else { + signatures = currentType.getIndexSignatures(); + } + } + + this._pushSymbol(signatures ? signatures[index] : null); + } + }; + + PullTypeEnclosingTypeWalker.prototype.postWalkSignature = function () { + if (this._canWalkStructure()) { + this._popSymbol(); + } + }; + + PullTypeEnclosingTypeWalker.prototype.walkTypeArgument = function (index) { + if (this._canWalkStructure()) { + var typeArgument = null; + var currentType = this._getCurrentSymbol(); + if (currentType) { + var typeArguments = currentType.getTypeArguments(); + typeArgument = typeArguments ? typeArguments[index] : null; + } + this._pushSymbol(typeArgument); + } + }; + + PullTypeEnclosingTypeWalker.prototype.postWalkTypeArgument = function () { + if (this._canWalkStructure()) { + this._popSymbol(); + } + }; + + PullTypeEnclosingTypeWalker.prototype.walkTypeParameterConstraint = function (index) { + if (this._canWalkStructure()) { + var typeParameters; + var currentSymbol = this._getCurrentSymbol(); + if (currentSymbol) { + if (currentSymbol.isSignature()) { + typeParameters = currentSymbol.getTypeParameters(); + } else { + TypeScript.Debug.assert(currentSymbol.isType()); + typeParameters = currentSymbol.getTypeParameters(); + } + } + this._pushSymbol(typeParameters ? typeParameters[index].getConstraint() : null); + } + }; + + PullTypeEnclosingTypeWalker.prototype.postWalkTypeParameterConstraint = function () { + if (this._canWalkStructure()) { + this._popSymbol(); + } + }; + + PullTypeEnclosingTypeWalker.prototype.walkReturnType = function () { + if (this._canWalkStructure()) { + var currentSignature = this._getCurrentSymbol(); + this._pushSymbol(currentSignature ? currentSignature.returnType : null); + } + }; + + PullTypeEnclosingTypeWalker.prototype.postWalkReturnType = function () { + if (this._canWalkStructure()) { + this._popSymbol(); + } + }; + + PullTypeEnclosingTypeWalker.prototype.walkParameterType = function (iParam) { + if (this._canWalkStructure()) { + var currentSignature = this._getCurrentSymbol(); + this._pushSymbol(currentSignature ? currentSignature.getParameterTypeAtIndex(iParam) : null); + } + }; + PullTypeEnclosingTypeWalker.prototype.postWalkParameterType = function () { + if (this._canWalkStructure()) { + this._popSymbol(); + } + }; + + PullTypeEnclosingTypeWalker.prototype.getBothKindOfIndexSignatures = function (resolver, context, includeAugmentedType) { + if (this._canWalkStructure()) { + var currentType = this._getCurrentSymbol(); + if (currentType) { + return resolver._getBothKindsOfIndexSignatures(currentType, context, includeAugmentedType); + } + } + return null; + }; + + PullTypeEnclosingTypeWalker.prototype.walkIndexSignatureReturnType = function (indexSigInfo, useStringIndexSignature, onlySignature) { + if (this._canWalkStructure()) { + var indexSig = indexSigInfo ? (useStringIndexSignature ? indexSigInfo.stringSignature : indexSigInfo.numericSignature) : null; + this._pushSymbol(indexSig); + if (!onlySignature) { + this._pushSymbol(indexSig ? indexSig.returnType : null); + } + } + }; + + PullTypeEnclosingTypeWalker.prototype.postWalkIndexSignatureReturnType = function (onlySignature) { + if (this._canWalkStructure()) { + if (!onlySignature) { + this._popSymbol(); + } + this._popSymbol(); + } + }; + return PullTypeEnclosingTypeWalker; + })(); + TypeScript.PullTypeEnclosingTypeWalker = PullTypeEnclosingTypeWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; (function (TypeScript) { var CandidateInferenceInfo = (function () { function CandidateInferenceInfo() { this.typeParameter = null; - this.isFixed = false; + this._inferredTypeAfterFixing = null; this.inferenceCandidates = []; } CandidateInferenceInfo.prototype.addCandidate = function (candidate) { - if (!this.isFixed) { + if (!this._inferredTypeAfterFixing) { this.inferenceCandidates[this.inferenceCandidates.length] = candidate; } }; + + CandidateInferenceInfo.prototype.isFixed = function () { + return !!this._inferredTypeAfterFixing; + }; + + CandidateInferenceInfo.prototype.fixTypeParameter = function (resolver, context) { + var _this = this; + if (!this._inferredTypeAfterFixing) { + var collection = { + getLength: function () { + return _this.inferenceCandidates.length; + }, + getTypeAtIndex: function (index) { + return _this.inferenceCandidates[index].type; + } + }; + + var bestCommonType = resolver.findBestCommonType(collection, context, new TypeScript.TypeComparisonInfo()); + this._inferredTypeAfterFixing = bestCommonType.widenedType(resolver, null, context); + } + }; return CandidateInferenceInfo; })(); TypeScript.CandidateInferenceInfo = CandidateInferenceInfo; - var ArgumentInferenceContext = (function () { - function ArgumentInferenceContext(resolver, argumentsOrParameters) { + var TypeArgumentInferenceContext = (function () { + function TypeArgumentInferenceContext(resolver, context, signatureBeingInferred) { + this.resolver = resolver; + this.context = context; + this.signatureBeingInferred = signatureBeingInferred; this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); this.candidateCache = []; - this.fixedParameterTypes = null; - this.resolver = null; - this.argumentASTs = null; - this.resolver = resolver; - - if (argumentsOrParameters.nonSeparatorAt != undefined) { - this.argumentASTs = argumentsOrParameters; - } else { - this.fixedParameterTypes = argumentsOrParameters; + var typeParameters = signatureBeingInferred.getTypeParameters(); + for (var i = 0; i < typeParameters.length; i++) { + this.addInferenceRoot(typeParameters[i]); } } - ArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { + TypeArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { if (this.inferenceCache.valueAt(objectType.pullSymbolID, parameterType.pullSymbolID)) { return true; } else { @@ -38389,12 +38973,12 @@ var TypeScript; } }; - ArgumentInferenceContext.prototype.resetRelationshipCache = function () { + TypeArgumentInferenceContext.prototype.resetRelationshipCache = function () { this.inferenceCache.release(); this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); }; - ArgumentInferenceContext.prototype.addInferenceRoot = function (param) { + TypeArgumentInferenceContext.prototype.addInferenceRoot = function (param) { var info = this.candidateCache[param.pullSymbolID]; if (!info) { @@ -38404,116 +38988,121 @@ var TypeScript; } }; - ArgumentInferenceContext.prototype.getInferenceInfo = function (param) { + TypeArgumentInferenceContext.prototype.getInferenceInfo = function (param) { return this.candidateCache[param.pullSymbolID]; }; - ArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate, fix) { + TypeArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate) { var info = this.getInferenceInfo(param); - if (info) { - if (candidate) { - info.addCandidate(candidate); - } - - if (!info.isFixed) { - info.isFixed = fix; - } + if (info && candidate && info.inferenceCandidates.indexOf(candidate) < 0) { + info.addCandidate(candidate); } }; - ArgumentInferenceContext.prototype.getInferenceArgumentCount = function () { - if (this.fixedParameterTypes) { - return this.fixedParameterTypes.length; - } else { - return this.argumentASTs.nonSeparatorCount(); + TypeArgumentInferenceContext.prototype.inferTypeArguments = function () { + throw TypeScript.Errors.abstract(); + }; + + TypeArgumentInferenceContext.prototype.fixTypeParameter = function (typeParameter) { + var candidateInfo = this.candidateCache[typeParameter.pullSymbolID]; + if (candidateInfo) { + candidateInfo.fixTypeParameter(this.resolver, this.context); } }; - ArgumentInferenceContext.prototype.getArgumentTypeSymbolAtIndex = function (i, context) { - TypeScript.Debug.assert(i >= 0, "invalid inference argument position"); - - if (this.fixedParameterTypes && i < this.getInferenceArgumentCount()) { - return this.fixedParameterTypes[i]; - } else if (i < this.getInferenceArgumentCount()) { - return this.resolver.resolveAST(this.argumentASTs.nonSeparatorAt(i), true, context).type; - } - - return null; - }; - - ArgumentInferenceContext.prototype.getInferenceCandidates = function () { - var inferenceCandidates = []; - - for (var infoKey in this.candidateCache) { - if (this.candidateCache.hasOwnProperty(infoKey)) { - var info = this.candidateCache[infoKey]; - - for (var i = 0; i < info.inferenceCandidates.length; i++) { - var val = []; - val[info.typeParameter.pullSymbolID] = info.inferenceCandidates[i]; - inferenceCandidates.push(val); - } - } - } - - return inferenceCandidates; - }; - - ArgumentInferenceContext.prototype.inferArgumentTypes = function (resolver, context) { - var collection; - - var bestCommonType; - + TypeArgumentInferenceContext.prototype._finalizeInferredTypeArguments = function () { var results = []; + var typeParameters = this.signatureBeingInferred.getTypeParameters(); + for (var i = 0; i < typeParameters.length; i++) { + var info = this.candidateCache[typeParameters[i].pullSymbolID]; - var unfit = false; + info.fixTypeParameter(this.resolver, this.context); - for (var infoKey in this.candidateCache) { - if (this.candidateCache.hasOwnProperty(infoKey)) { - var info = this.candidateCache[infoKey]; - - if (!info.inferenceCandidates.length) { - results[results.length] = { param: info.typeParameter, type: null }; - continue; + for (var i = 0; i < results.length; i++) { + if (results[i].type === info.typeParameter) { + results[i].type = info._inferredTypeAfterFixing; } - - collection = { - getLength: function () { - return info.inferenceCandidates.length; - }, - getTypeAtIndex: function (index) { - return info.inferenceCandidates[index].type; - } - }; - - bestCommonType = resolver.widenType(resolver.findBestCommonType(collection, context, new TypeScript.TypeComparisonInfo())); - - if (!bestCommonType) { - unfit = true; - } else { - for (var i = 0; i < results.length; i++) { - if (results[i].type == info.typeParameter) { - results[i].type = bestCommonType; - } - } - } - - results[results.length] = { param: info.typeParameter, type: bestCommonType }; } + + results.push(info._inferredTypeAfterFixing); } - return { results: results, unfit: unfit }; + return results; }; - return ArgumentInferenceContext; + + TypeArgumentInferenceContext.prototype.isInvocationInferenceContext = function () { + throw TypeScript.Errors.abstract(); + }; + return TypeArgumentInferenceContext; })(); - TypeScript.ArgumentInferenceContext = ArgumentInferenceContext; + TypeScript.TypeArgumentInferenceContext = TypeArgumentInferenceContext; + + var InvocationTypeArgumentInferenceContext = (function (_super) { + __extends(InvocationTypeArgumentInferenceContext, _super); + function InvocationTypeArgumentInferenceContext(resolver, context, signatureBeingInferred, argumentASTs) { + _super.call(this, resolver, context, signatureBeingInferred); + this.argumentASTs = argumentASTs; + } + InvocationTypeArgumentInferenceContext.prototype.isInvocationInferenceContext = function () { + return true; + }; + + InvocationTypeArgumentInferenceContext.prototype.inferTypeArguments = function () { + var _this = this; + this.signatureBeingInferred.forAllParameterTypes(this.argumentASTs.nonSeparatorCount(), function (parameterType, argumentIndex) { + var argumentAST = _this.argumentASTs.nonSeparatorAt(argumentIndex); + + _this.context.pushInferentialType(parameterType, _this); + var argumentType = _this.resolver.resolveAST(argumentAST, true, _this.context).type; + _this.resolver.relateTypeToTypeParametersWithNewEnclosingTypes(argumentType, parameterType, _this, _this.context); + _this.context.popAnyContextualType(); + + return true; + }); + + return this._finalizeInferredTypeArguments(); + }; + return InvocationTypeArgumentInferenceContext; + })(TypeArgumentInferenceContext); + TypeScript.InvocationTypeArgumentInferenceContext = InvocationTypeArgumentInferenceContext; + + var ContextualSignatureInstantiationTypeArgumentInferenceContext = (function (_super) { + __extends(ContextualSignatureInstantiationTypeArgumentInferenceContext, _super); + function ContextualSignatureInstantiationTypeArgumentInferenceContext(resolver, context, signatureBeingInferred, contextualSignature, shouldFixContextualSignatureParameterTypes) { + _super.call(this, resolver, context, signatureBeingInferred); + this.contextualSignature = contextualSignature; + this.shouldFixContextualSignatureParameterTypes = shouldFixContextualSignatureParameterTypes; + } + ContextualSignatureInstantiationTypeArgumentInferenceContext.prototype.isInvocationInferenceContext = function () { + return false; + }; + + ContextualSignatureInstantiationTypeArgumentInferenceContext.prototype.inferTypeArguments = function () { + var _this = this; + var relateTypesCallback = function (parameterTypeBeingInferred, contextualParameterType) { + if (_this.shouldFixContextualSignatureParameterTypes) { + contextualParameterType = _this.context.fixAllTypeParametersReferencedByType(contextualParameterType, _this.resolver, _this); + } + _this.resolver.relateTypeToTypeParametersWithNewEnclosingTypes(contextualParameterType, parameterTypeBeingInferred, _this, _this.context); + + return true; + }; + + this.signatureBeingInferred.forAllCorrespondingParameterTypesInThisAndOtherSignature(this.contextualSignature, relateTypesCallback); + + return this._finalizeInferredTypeArguments(); + }; + return ContextualSignatureInstantiationTypeArgumentInferenceContext; + })(TypeArgumentInferenceContext); + TypeScript.ContextualSignatureInstantiationTypeArgumentInferenceContext = ContextualSignatureInstantiationTypeArgumentInferenceContext; var PullContextualTypeContext = (function () { - function PullContextualTypeContext(contextualType, provisional, substitutions) { + function PullContextualTypeContext(contextualType, provisional, isInferentiallyTyping, typeArgumentInferenceContext) { this.contextualType = contextualType; this.provisional = provisional; - this.substitutions = substitutions; + this.isInferentiallyTyping = isInferentiallyTyping; + this.typeArgumentInferenceContext = typeArgumentInferenceContext; this.provisionallyTypedSymbols = []; this.hasProvisionalErrors = false; this.astSymbolMap = []; @@ -38548,6 +39137,8 @@ var TypeScript; this.fileName = fileName; this.contextStack = []; this.typeCheckedNodes = null; + this.enclosingTypeWalker1 = null; + this.enclosingTypeWalker2 = null; this.inBaseTypeResolution = false; if (inTypeCheck) { TypeScript.Debug.assert(fileName, "A file name must be provided if you are typechecking"); @@ -38564,11 +39155,27 @@ var TypeScript; return this.typeCheck() && !this.typeCheckedNodes.valueAt(ast.syntaxID()) && this.fileName === ast.fileName(); }; - PullTypeResolutionContext.prototype.pushContextualType = function (type, provisional, substitutions) { - this.contextStack.push(new PullContextualTypeContext(type, provisional, substitutions)); + PullTypeResolutionContext.prototype._pushAnyContextualType = function (type, provisional, isInferentiallyTyping, argContext) { + this.contextStack.push(new PullContextualTypeContext(type, provisional, isInferentiallyTyping, argContext)); }; - PullTypeResolutionContext.prototype.popContextualType = function () { + PullTypeResolutionContext.prototype.pushNewContextualType = function (type) { + this._pushAnyContextualType(type, this.inProvisionalResolution(), false, null); + }; + + PullTypeResolutionContext.prototype.propagateContextualType = function (type) { + this._pushAnyContextualType(type, this.inProvisionalResolution(), this.isInferentiallyTyping(), this.getCurrentTypeArgumentInferenceContext()); + }; + + PullTypeResolutionContext.prototype.pushInferentialType = function (type, typeArgumentInferenceContext) { + this._pushAnyContextualType(type, true, true, typeArgumentInferenceContext); + }; + + PullTypeResolutionContext.prototype.pushProvisionalType = function (type) { + this._pushAnyContextualType(type, true, false, null); + }; + + PullTypeResolutionContext.prototype.popAnyContextualType = function () { var tc = this.contextStack.pop(); tc.invalidateProvisionallyTypedSymbols(); @@ -38584,24 +39191,6 @@ var TypeScript; return this.contextStack.length ? this.contextStack[this.contextStack.length - 1].hasProvisionalErrors : false; }; - PullTypeResolutionContext.prototype.findSubstitution = function (type) { - var substitution = null; - - if (this.contextStack.length) { - for (var i = this.contextStack.length - 1; i >= 0; i--) { - if (this.contextStack[i].substitutions) { - substitution = this.contextStack[i].substitutions[type.pullSymbolID]; - - if (substitution) { - break; - } - } - } - } - - return substitution; - }; - PullTypeResolutionContext.prototype.getContextualType = function () { var context = !this.contextStack.length ? null : this.contextStack[this.contextStack.length - 1]; @@ -38612,18 +39201,44 @@ var TypeScript; return null; } - if (type.isTypeParameter() && type.getConstraint()) { - type = type.getConstraint(); - } - - var substitution = this.findSubstitution(type); - - return substitution ? substitution : type; + return type; } return null; }; + PullTypeResolutionContext.prototype.fixAllTypeParametersReferencedByType = function (type, resolver, argContext) { + var argContext = this.getCurrentTypeArgumentInferenceContext(); + if (type.wrapsSomeTypeParameter(argContext.candidateCache)) { + var typeParameterArgumentMap = []; + + for (var n in argContext.candidateCache) { + var typeParameter = argContext.candidateCache[n] && argContext.candidateCache[n].typeParameter; + if (typeParameter) { + var dummyMap = []; + dummyMap[typeParameter.pullSymbolID] = typeParameter; + if (type.wrapsSomeTypeParameter(dummyMap)) { + argContext.fixTypeParameter(typeParameter); + TypeScript.Debug.assert(argContext.candidateCache[n]._inferredTypeAfterFixing); + typeParameterArgumentMap[typeParameter.pullSymbolID] = argContext.candidateCache[n]._inferredTypeAfterFixing; + } + } + } + + return resolver.instantiateType(type, typeParameterArgumentMap); + } + + return type; + }; + + PullTypeResolutionContext.prototype.getCurrentTypeArgumentInferenceContext = function () { + return this.contextStack.length ? this.contextStack[this.contextStack.length - 1].typeArgumentInferenceContext : null; + }; + + PullTypeResolutionContext.prototype.isInferentiallyTyping = function () { + return this.contextStack.length > 0 && this.contextStack[this.contextStack.length - 1].isInferentiallyTyping; + }; + PullTypeResolutionContext.prototype.inProvisionalResolution = function () { return (!this.contextStack.length ? false : this.contextStack[this.contextStack.length - 1].provisional); }; @@ -38643,9 +39258,10 @@ var TypeScript; }; PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, type) { - var substitution = this.findSubstitution(type); - - symbol.type = substitution ? substitution : type; + if (symbol.type && symbol.type.isError() && !type.isError()) { + return; + } + symbol.type = type; if (this.contextStack.length && this.inProvisionalResolution()) { this.contextStack[this.contextStack.length - 1].recordProvisionallyTypedSymbol(symbol); @@ -38685,6 +39301,145 @@ var TypeScript; return null; }; + + PullTypeResolutionContext.prototype.startWalkingTypes = function (symbol1, symbol2) { + if (!this.enclosingTypeWalker1) { + this.enclosingTypeWalker1 = new TypeScript.PullTypeEnclosingTypeWalker(); + } + var symbolsWhenStartedWalkingTypes1 = this.enclosingTypeWalker1.startWalkingType(symbol1); + if (!this.enclosingTypeWalker2) { + this.enclosingTypeWalker2 = new TypeScript.PullTypeEnclosingTypeWalker(); + } + var symbolsWhenStartedWalkingTypes2 = this.enclosingTypeWalker2.startWalkingType(symbol2); + return { symbolsWhenStartedWalkingTypes1: symbolsWhenStartedWalkingTypes1, symbolsWhenStartedWalkingTypes2: symbolsWhenStartedWalkingTypes2 }; + }; + + PullTypeResolutionContext.prototype.endWalkingTypes = function (symbolsWhenStartedWalkingTypes) { + this.enclosingTypeWalker1.endWalkingType(symbolsWhenStartedWalkingTypes.symbolsWhenStartedWalkingTypes1); + this.enclosingTypeWalker2.endWalkingType(symbolsWhenStartedWalkingTypes.symbolsWhenStartedWalkingTypes2); + }; + + PullTypeResolutionContext.prototype.setEnclosingTypes = function (symbol1, symbol2) { + if (!this.enclosingTypeWalker1) { + this.enclosingTypeWalker1 = new TypeScript.PullTypeEnclosingTypeWalker(); + } + this.enclosingTypeWalker1.setEnclosingType(symbol1); + if (!this.enclosingTypeWalker2) { + this.enclosingTypeWalker2 = new TypeScript.PullTypeEnclosingTypeWalker(); + } + this.enclosingTypeWalker2.setEnclosingType(symbol2); + }; + + PullTypeResolutionContext.prototype.walkMemberTypes = function (memberName) { + this.enclosingTypeWalker1.walkMemberType(memberName, this.resolver); + this.enclosingTypeWalker2.walkMemberType(memberName, this.resolver); + }; + + PullTypeResolutionContext.prototype.postWalkMemberTypes = function () { + this.enclosingTypeWalker1.postWalkMemberType(); + this.enclosingTypeWalker2.postWalkMemberType(); + }; + + PullTypeResolutionContext.prototype.walkSignatures = function (kind, index, index2) { + this.enclosingTypeWalker1.walkSignature(kind, index); + this.enclosingTypeWalker2.walkSignature(kind, index2 == undefined ? index : index2); + }; + + PullTypeResolutionContext.prototype.postWalkSignatures = function () { + this.enclosingTypeWalker1.postWalkSignature(); + this.enclosingTypeWalker2.postWalkSignature(); + }; + + PullTypeResolutionContext.prototype.walkTypeParameterConstraints = function (index) { + this.enclosingTypeWalker1.walkTypeParameterConstraint(index); + this.enclosingTypeWalker2.walkTypeParameterConstraint(index); + }; + + PullTypeResolutionContext.prototype.postWalkTypeParameterConstraints = function () { + this.enclosingTypeWalker1.postWalkTypeParameterConstraint(); + this.enclosingTypeWalker2.postWalkTypeParameterConstraint(); + }; + + PullTypeResolutionContext.prototype.walkTypeArgument = function (index) { + this.enclosingTypeWalker1.walkTypeArgument(index); + this.enclosingTypeWalker2.walkTypeArgument(index); + }; + + PullTypeResolutionContext.prototype.postWalkTypeArgument = function () { + this.enclosingTypeWalker1.postWalkTypeArgument(); + this.enclosingTypeWalker2.postWalkTypeArgument(); + }; + + PullTypeResolutionContext.prototype.walkReturnTypes = function () { + this.enclosingTypeWalker1.walkReturnType(); + this.enclosingTypeWalker2.walkReturnType(); + }; + + PullTypeResolutionContext.prototype.postWalkReturnTypes = function () { + this.enclosingTypeWalker1.postWalkReturnType(); + this.enclosingTypeWalker2.postWalkReturnType(); + }; + + PullTypeResolutionContext.prototype.walkParameterTypes = function (iParam) { + this.enclosingTypeWalker1.walkParameterType(iParam); + this.enclosingTypeWalker2.walkParameterType(iParam); + }; + + PullTypeResolutionContext.prototype.postWalkParameterTypes = function () { + this.enclosingTypeWalker1.postWalkParameterType(); + this.enclosingTypeWalker2.postWalkParameterType(); + }; + + PullTypeResolutionContext.prototype.getBothKindOfIndexSignatures = function (includeAugmentedType1, includeAugmentedType2) { + var indexSigs1 = this.enclosingTypeWalker1.getBothKindOfIndexSignatures(this.resolver, this, includeAugmentedType1); + var indexSigs2 = this.enclosingTypeWalker2.getBothKindOfIndexSignatures(this.resolver, this, includeAugmentedType2); + return { indexSigs1: indexSigs1, indexSigs2: indexSigs2 }; + }; + + PullTypeResolutionContext.prototype.walkIndexSignatureReturnTypes = function (indexSigs, useStringIndexSignature1, useStringIndexSignature2, onlySignature) { + this.enclosingTypeWalker1.walkIndexSignatureReturnType(indexSigs.indexSigs1, useStringIndexSignature1, onlySignature); + this.enclosingTypeWalker2.walkIndexSignatureReturnType(indexSigs.indexSigs2, useStringIndexSignature2, onlySignature); + }; + + PullTypeResolutionContext.prototype.postWalkIndexSignatureReturnTypes = function (onlySignature) { + this.enclosingTypeWalker1.postWalkIndexSignatureReturnType(onlySignature); + this.enclosingTypeWalker2.postWalkIndexSignatureReturnType(onlySignature); + }; + + PullTypeResolutionContext.prototype.swapEnclosingTypeWalkers = function () { + var tempEnclosingWalker1 = this.enclosingTypeWalker1; + this.enclosingTypeWalker1 = this.enclosingTypeWalker2; + this.enclosingTypeWalker2 = tempEnclosingWalker1; + }; + + PullTypeResolutionContext.prototype.oneOfClassificationsIsInfinitelyExpanding = function () { + var generativeClassification1 = this.enclosingTypeWalker1.getGenerativeClassification(); + if (generativeClassification1 === 3 /* InfinitelyExpanding */) { + return true; + } + var generativeClassification2 = this.enclosingTypeWalker2.getGenerativeClassification(); + if (generativeClassification2 === 3 /* InfinitelyExpanding */) { + return true; + } + + return false; + }; + + PullTypeResolutionContext.prototype.resetEnclosingTypeWalkers = function () { + var enclosingTypeWalker1 = this.enclosingTypeWalker1; + var enclosingTypeWalker2 = this.enclosingTypeWalker2; + this.enclosingTypeWalker1 = null; + this.enclosingTypeWalker2 = null; + return { + enclosingTypeWalker1: enclosingTypeWalker1, + enclosingTypeWalker2: enclosingTypeWalker2 + }; + }; + + PullTypeResolutionContext.prototype.setEnclosingTypeWalkers = function (enclosingTypeWalkers) { + this.enclosingTypeWalker1 = enclosingTypeWalkers.enclosingTypeWalker1; + this.enclosingTypeWalker2 = enclosingTypeWalkers.enclosingTypeWalker2; + }; return PullTypeResolutionContext; })(); TypeScript.PullTypeResolutionContext = PullTypeResolutionContext; @@ -38741,20 +39496,19 @@ var TypeScript; return InheritedIndexSignatureInfo; })(); - var CompilerReservedNames; - (function (CompilerReservedNames) { - CompilerReservedNames[CompilerReservedNames["_this"] = 1] = "_this"; - CompilerReservedNames[CompilerReservedNames["_super"] = 2] = "_super"; - CompilerReservedNames[CompilerReservedNames["arguments"] = 3] = "arguments"; - CompilerReservedNames[CompilerReservedNames["_i"] = 4] = "_i"; - CompilerReservedNames[CompilerReservedNames["require"] = 5] = "require"; - CompilerReservedNames[CompilerReservedNames["exports"] = 6] = "exports"; - })(CompilerReservedNames || (CompilerReservedNames = {})); + var CompilerReservedName; + (function (CompilerReservedName) { + CompilerReservedName[CompilerReservedName["_this"] = 1] = "_this"; + CompilerReservedName[CompilerReservedName["_super"] = 2] = "_super"; + CompilerReservedName[CompilerReservedName["arguments"] = 3] = "arguments"; + CompilerReservedName[CompilerReservedName["_i"] = 4] = "_i"; + CompilerReservedName[CompilerReservedName["require"] = 5] = "require"; + CompilerReservedName[CompilerReservedName["exports"] = 6] = "exports"; + })(CompilerReservedName || (CompilerReservedName = {})); function getCompilerReservedName(name) { var nameText = name.valueText(); - var index = CompilerReservedNames[nameText]; - return CompilerReservedNames[index] ? index : undefined; + return CompilerReservedName[nameText]; } var PullTypeResolver = (function () { @@ -38776,14 +39530,11 @@ var TypeScript; this.assignableCache = TypeScript.BitMatrix.getBitMatrix(true); this.subtypeCache = TypeScript.BitMatrix.getBitMatrix(true); this.identicalCache = TypeScript.BitMatrix.getBitMatrix(true); + this.inResolvingOtherDeclsWalker = new TypeScript.PullHelpers.OtherPullDeclsWalker(); } PullTypeResolver.prototype.cachedArrayInterfaceType = function () { if (!this._cachedArrayInterfaceType) { - this._cachedArrayInterfaceType = this.getSymbolFromDeclPath("Array", [], 16 /* Interface */); - } - - if (!this._cachedArrayInterfaceType) { - this._cachedArrayInterfaceType = this.semanticInfoChain.anyTypeSymbol; + this._cachedArrayInterfaceType = this.getSymbolFromDeclPath("Array", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; } if (!this._cachedArrayInterfaceType.isResolved) { @@ -38799,7 +39550,7 @@ var TypeScript; PullTypeResolver.prototype.cachedNumberInterfaceType = function () { if (!this._cachedNumberInterfaceType) { - this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */); + this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; } if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved) { @@ -38811,7 +39562,7 @@ var TypeScript; PullTypeResolver.prototype.cachedStringInterfaceType = function () { if (!this._cachedStringInterfaceType) { - this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */); + this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; } if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved) { @@ -38823,7 +39574,7 @@ var TypeScript; PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { if (!this._cachedBooleanInterfaceType) { - this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */); + this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; } if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved) { @@ -38835,7 +39586,7 @@ var TypeScript; PullTypeResolver.prototype.cachedObjectInterfaceType = function () { if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */); + this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; } if (!this._cachedObjectInterfaceType) { @@ -38851,7 +39602,7 @@ var TypeScript; PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { if (!this._cachedFunctionInterfaceType) { - this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */); + this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; } if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved) { @@ -38863,7 +39614,7 @@ var TypeScript; PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { if (!this._cachedIArgumentsInterfaceType) { - this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */); + this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; } if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved) { @@ -38875,7 +39626,7 @@ var TypeScript; PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { if (!this._cachedRegExpInterfaceType) { - this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */); + this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; } if (this._cachedRegExpInterfaceType && !this._cachedRegExpInterfaceType.isResolved) { @@ -38888,10 +39639,10 @@ var TypeScript; PullTypeResolver.prototype.cachedFunctionArgumentsSymbol = function () { if (!this._cachedFunctionArgumentsSymbol) { this._cachedFunctionArgumentsSymbol = new TypeScript.PullSymbol("arguments", 512 /* Variable */); - this._cachedFunctionArgumentsSymbol.type = this.cachedIArgumentsInterfaceType() ? this.cachedIArgumentsInterfaceType() : this.semanticInfoChain.anyTypeSymbol; + this._cachedFunctionArgumentsSymbol.type = this.cachedIArgumentsInterfaceType() || this.semanticInfoChain.anyTypeSymbol; this._cachedFunctionArgumentsSymbol.setResolved(); - var functionArgumentsDecl = new TypeScript.PullSynthesizedDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, null, new TypeScript.TextSpan(0, 0), this.semanticInfoChain); + var functionArgumentsDecl = new TypeScript.PullSynthesizedDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, null, this.semanticInfoChain); functionArgumentsDecl.setSymbol(this._cachedFunctionArgumentsSymbol); this._cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); } @@ -38899,6 +39650,33 @@ var TypeScript; return this._cachedFunctionArgumentsSymbol; }; + PullTypeResolver.prototype.getApparentType = function (type) { + if (type.isTypeParameter()) { + var baseConstraint = type.getBaseConstraint(this.semanticInfoChain); + if (baseConstraint === this.semanticInfoChain.anyTypeSymbol) { + return this.semanticInfoChain.emptyTypeSymbol; + } else { + type = baseConstraint; + } + } + if (type.isPrimitive()) { + if (type === this.semanticInfoChain.numberTypeSymbol) { + return this.cachedNumberInterfaceType(); + } + if (type === this.semanticInfoChain.booleanTypeSymbol) { + return this.cachedBooleanInterfaceType(); + } + if (type === this.semanticInfoChain.stringTypeSymbol) { + return this.cachedStringInterfaceType(); + } + return type; + } + if (type.isEnum()) { + return this.cachedNumberInterfaceType(); + } + return type; + }; + PullTypeResolver.prototype.setTypeChecked = function (ast, context) { context.setTypeChecked(ast); }; @@ -38948,7 +39726,7 @@ var TypeScript; PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { if (!(symbol.kind & (65536 /* Method */ | 4096 /* Property */))) { - var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) != 0; + var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) !== 0; var containerType = !isContainer ? parent.getAssociatedContainerType() : parent; if (isContainer && containerType) { @@ -38963,12 +39741,32 @@ var TypeScript; return symbol; }; - PullTypeResolver.prototype.getMemberSymbol = function (symbolName, declSearchKind, parent) { + PullTypeResolver.prototype._getNamedPropertySymbolOfAugmentedType = function (symbolName, parent) { + var memberSymbol = this.getNamedPropertySymbol(symbolName, 68147712 /* SomeValue */, parent); + if (memberSymbol) { + return memberSymbol; + } + + if (this.cachedFunctionInterfaceType() && parent.isFunctionType()) { + memberSymbol = this.cachedFunctionInterfaceType().findMember(symbolName, true); + if (memberSymbol) { + return memberSymbol; + } + } + + if (this.cachedObjectInterfaceType()) { + return this.cachedObjectInterfaceType().findMember(symbolName, true); + } + + return null; + }; + + PullTypeResolver.prototype.getNamedPropertySymbol = function (symbolName, declSearchKind, parent) { var member = null; if (declSearchKind & 68147712 /* SomeValue */) { member = parent.findMember(symbolName, true); - } else if (declSearchKind & 58728539 /* SomeType */) { + } else if (declSearchKind & 58728795 /* SomeType */) { member = parent.findNestedType(symbolName); } else if (declSearchKind & 164 /* SomeContainer */) { member = parent.findNestedContainer(symbolName); @@ -38989,7 +39787,7 @@ var TypeScript; if (declSearchKind & 68147712 /* SomeValue */) { member = parent.findMember(symbolName, true); - } else if (declSearchKind & 58728539 /* SomeType */) { + } else if (declSearchKind & 58728795 /* SomeType */) { member = parent.findNestedType(symbolName); } else if (declSearchKind & 164 /* SomeContainer */) { member = parent.findNestedContainer(symbolName); @@ -39016,12 +39814,12 @@ var TypeScript; return this.getExportedMemberSymbol(member, parent); } - if ((declSearchKind & 58728539 /* SomeType */) != 0 || (declSearchKind & 68147712 /* SomeValue */) != 0) { + if ((declSearchKind & 58728795 /* SomeType */) !== 0 || (declSearchKind & 68147712 /* SomeValue */) !== 0) { childDecls = typeDeclarations[j].searchChildDecls(symbolName, 128 /* TypeAlias */); - if (childDecls.length && childDecls[0].kind == 128 /* TypeAlias */) { + if (childDecls.length && childDecls[0].kind === 128 /* TypeAlias */) { var aliasSymbol = this.getExportedMemberSymbol(childDecls[0].getSymbol(), parent); if (aliasSymbol) { - if ((declSearchKind & 58728539 /* SomeType */) != 0) { + if ((declSearchKind & 58728795 /* SomeType */) !== 0) { var typeSymbol = aliasSymbol.getExportAssignedTypeSymbol(); if (typeSymbol) { return typeSymbol; @@ -39029,9 +39827,12 @@ var TypeScript; } else { var valueSymbol = aliasSymbol.getExportAssignedValueSymbol(); if (valueSymbol) { + aliasSymbol.setIsUsedAsValue(); return valueSymbol; } } + + return aliasSymbol; } } } @@ -39040,6 +39841,7 @@ var TypeScript; }; PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { + var _this = this; var symbol = null; var decl = null; @@ -39053,6 +39855,61 @@ var TypeScript; var instanceType = null; var childSymbol = null; + var allowedContainerDeclKind = 4 /* Container */ | 32 /* DynamicModule */; + if (TypeScript.hasFlag(declSearchKind, 67108864 /* EnumMember */)) { + allowedContainerDeclKind |= 64 /* Enum */; + } + + var isAcceptableAlias = function (symbol) { + if (symbol.isAlias()) { + _this.resolveDeclaredSymbol(symbol); + if (TypeScript.hasFlag(declSearchKind, 164 /* SomeContainer */)) { + if (symbol.assignedContainer() || symbol.getExportAssignedContainerSymbol()) { + return true; + } + } else if (TypeScript.hasFlag(declSearchKind, 58728795 /* SomeType */)) { + var type = symbol.getExportAssignedTypeSymbol(); + if (type && type.kind !== 32 /* DynamicModule */) { + return true; + } + + var type = symbol.assignedType(); + if (type && type.kind !== 32 /* DynamicModule */) { + return true; + } + } else if (TypeScript.hasFlag(declSearchKind, 68147712 /* SomeValue */ & ~67108864 /* EnumMember */)) { + if (symbol.assignedType() && symbol.assignedType().isError()) { + return true; + } else if (symbol.assignedValue() || symbol.getExportAssignedValueSymbol()) { + return true; + } else { + var assignedType = symbol.assignedType(); + if (assignedType && assignedType.isContainer() && assignedType.getInstanceType()) { + return true; + } + + var decls = symbol.getDeclarations(); + var ast = decls[0].ast(); + return ast.moduleReference.kind() === 245 /* ExternalModuleReference */; + } + } + } + + return false; + }; + + var tryFindAlias = function (decl) { + var childDecls = decl.searchChildDecls(symbolName, 128 /* TypeAlias */); + + if (childDecls.length) { + var sym = childDecls[0].getSymbol(); + if (isAcceptableAlias(sym)) { + return sym; + } + } + return null; + }; + for (var i = declPath.length - 1; i >= 0; i--) { decl = declPath[i]; pathDeclKind = decl.kind; @@ -39061,30 +39918,25 @@ var TypeScript; return this.semanticInfoChain.anyTypeSymbol; } - if (pathDeclKind & (4 /* Container */ | 32 /* DynamicModule */)) { + if (pathDeclKind & allowedContainerDeclKind) { childDecls = decl.searchChildDecls(symbolName, declSearchKind); if (childDecls.length) { return childDecls[0].getSymbol(); } + var alias = tryFindAlias(decl); + if (alias) { + return alias; + } + if (declSearchKind & 68147712 /* SomeValue */) { instanceSymbol = decl.getSymbol().getInstanceSymbol(); - childDecls = decl.searchChildDecls(symbolName, 128 /* TypeAlias */); - - if (childDecls.length) { - var sym = childDecls[0].getSymbol(); - - if (sym.isAlias()) { - return sym; - } - } - if (instanceSymbol) { instanceType = instanceSymbol.type; - childSymbol = this.getMemberSymbol(symbolName, declSearchKind, instanceType); + childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, instanceType); if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { return childSymbol; @@ -39100,12 +39952,12 @@ var TypeScript; declSymbol = decl.getSymbol().type; - var childSymbol = this.getMemberSymbol(symbolName, declSearchKind, declSymbol); + var childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, declSymbol); if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { return childSymbol; } - } else if ((declSearchKind & (58728539 /* SomeType */ | 164 /* SomeContainer */)) || !(pathDeclKind & 8 /* Class */)) { + } else if ((declSearchKind & (58728795 /* SomeType */ | 164 /* SomeContainer */)) || !(pathDeclKind & 8 /* Class */)) { var candidateSymbol = null; if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === decl.getFunctionExpressionName()) { @@ -39125,23 +39977,26 @@ var TypeScript; return candidateSymbol; } - if (declSearchKind & 68147712 /* SomeValue */) { - childDecls = decl.searchChildDecls(symbolName, 128 /* TypeAlias */); - - if (childDecls.length) { - var sym = childDecls[0].getSymbol(); - - if (sym.isAlias()) { - return sym; - } - } + var alias = tryFindAlias(decl); + if (alias) { + return alias; } } } symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); + if (symbol) { + return symbol; + } - return symbol; + if (!TypeScript.hasFlag(declSearchKind, 128 /* TypeAlias */)) { + symbol = this.semanticInfoChain.findSymbol([symbolName], 128 /* TypeAlias */); + if (symbol && isAcceptableAlias(symbol)) { + return symbol; + } + } + + return null; }; PullTypeResolver.prototype.getVisibleDeclsFromDeclPath = function (declPath, declSearchKind) { @@ -39237,7 +40092,7 @@ var TypeScript; PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl) { var declPath = enclosingDecl.getParentPath(); - var declSearchKind = 58728539 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); }; @@ -39248,7 +40103,7 @@ var TypeScript; return null; } - var declSearchKind = 58728539 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; var members = contextualTypeSymbol.getAllMembers(declSearchKind, 2 /* externallyVisible */); for (var i = 0; i < members.length; i++) { @@ -39261,7 +40116,7 @@ var TypeScript; PullTypeResolver.prototype.getVisibleMembersFromExpression = function (expression, enclosingDecl, context) { var lhs = this.resolveAST(expression, false, context); - if (isTypesOnlyLocation(expression) && (lhs.kind === 8 /* Class */ || lhs.kind === 16 /* Interface */)) { + if (isTypesOnlyLocation(expression) && (lhs.kind === 8 /* Class */ || lhs.kind === 16 /* Interface */ || lhs.kind === 64 /* Enum */)) { return null; } @@ -39276,13 +40131,6 @@ var TypeScript; lhsType = lhsType.getExportAssignedTypeSymbol(); } - while (lhsType.isTypeParameter()) { - lhsType = lhsType.getConstraint(); - if (!lhsType) { - return null; - } - } - if (this.isAnyOrEquivalent(lhsType)) { return null; } @@ -39307,7 +40155,7 @@ var TypeScript; } } - var declSearchKind = 58728539 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; var members = []; @@ -39318,66 +40166,47 @@ var TypeScript; } } - if (lhsType.isTypeParameter()) { - var constraint = lhsType.getConstraint(); + lhsType = this.getApparentType(lhsType); - if (constraint) { - lhsType = constraint; - members = lhsType.getAllMembers(declSearchKind, 2 /* externallyVisible */); - } - } else { - if (lhs.kind == 67108864 /* EnumMember */) { - lhsType = this.semanticInfoChain.numberTypeSymbol; - } + if (!lhsType.isResolved) { + var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); - if (lhsType === this.semanticInfoChain.numberTypeSymbol && this.cachedNumberInterfaceType()) { - lhsType = this.cachedNumberInterfaceType(); - } else if (lhsType === this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { - lhsType = this.cachedStringInterfaceType(); - } else if (lhsType === this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { - lhsType = this.cachedBooleanInterfaceType(); - } - - if (!lhsType.isResolved) { - var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); - - if (potentiallySpecializedType != lhsType) { - if (!lhs.isType()) { - context.setTypeInContext(lhs, potentiallySpecializedType); - } - - lhsType = potentiallySpecializedType; - } - } - - members = lhsType.getAllMembers(declSearchKind, memberVisibilty); - - if (lhsType.isContainer()) { - var associatedInstance = lhsType.getInstanceSymbol(); - if (associatedInstance) { - var instanceType = associatedInstance.type; - this.resolveDeclaredSymbol(instanceType, context); - var instanceMembers = instanceType.getAllMembers(declSearchKind, memberVisibilty); - members = members.concat(instanceMembers); + if (potentiallySpecializedType !== lhsType) { + if (!lhs.isType()) { + context.setTypeInContext(lhs, potentiallySpecializedType); } - var exportedContainer = lhsType.getExportAssignedContainerSymbol(); - if (exportedContainer) { - var exportedContainerMembers = exportedContainer.getAllMembers(declSearchKind, memberVisibilty); - members = members.concat(exportedContainerMembers); - } - } else if (!lhsType.isConstructor()) { - var associatedContainerSymbol = lhsType.getAssociatedContainerType(); - if (associatedContainerSymbol) { - var containerType = associatedContainerSymbol.type; - this.resolveDeclaredSymbol(containerType, context); - var containerMembers = containerType.getAllMembers(declSearchKind, memberVisibilty); - members = members.concat(containerMembers); - } + lhsType = potentiallySpecializedType; } } - if ((lhsType.getCallSignatures().length || lhsType.getConstructSignatures().length) && this.cachedFunctionInterfaceType()) { + members = lhsType.getAllMembers(declSearchKind, memberVisibilty); + + if (lhsType.isContainer()) { + var associatedInstance = lhsType.getInstanceSymbol(); + if (associatedInstance) { + var instanceType = associatedInstance.type; + this.resolveDeclaredSymbol(instanceType, context); + var instanceMembers = instanceType.getAllMembers(declSearchKind, memberVisibilty); + members = members.concat(instanceMembers); + } + + var exportedContainer = lhsType.getExportAssignedContainerSymbol(); + if (exportedContainer) { + var exportedContainerMembers = exportedContainer.getAllMembers(declSearchKind, memberVisibilty); + members = members.concat(exportedContainerMembers); + } + } else if (!lhsType.isConstructor() && !lhsType.isEnum()) { + var associatedContainerSymbol = lhsType.getAssociatedContainerType(); + if (associatedContainerSymbol) { + var containerType = associatedContainerSymbol.type; + this.resolveDeclaredSymbol(containerType, context); + var containerMembers = containerType.getAllMembers(declSearchKind, memberVisibilty); + members = members.concat(containerMembers); + } + } + + if (lhsType.isFunctionType() && this.cachedFunctionInterfaceType()) { members = members.concat(this.cachedFunctionInterfaceType().getAllMembers(declSearchKind, 2 /* externallyVisible */)); } @@ -39456,22 +40285,26 @@ var TypeScript; return symbol; } - if (ast.kind() === 11 /* IdentifierName */ && ast.parent && ast.parent.kind() === 236 /* CatchClause */) { + if (ast.parent && ast.parent.kind() === 236 /* CatchClause */ && ast.parent.identifier === ast) { return symbol; } - var enclosingModule = TypeScript.getEnclosingModuleDeclaration(ast); + if (ast.parent && ast.parent.kind() === 219 /* SimpleArrowFunctionExpression */ && ast.parent.identifier === ast) { + return symbol; + } + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(ast); var resolvedSymbol; - if (TypeScript.isAnyNameOfModule(enclosingModule, ast)) { + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, ast)) { resolvedSymbol = this.resolveSingleModuleDeclaration(enclosingModule, ast, context); } else if (ast.kind() === 120 /* SourceUnit */ && decl.kind === 32 /* DynamicModule */) { resolvedSymbol = this.resolveModuleSymbol(decl.getSymbol(), context, null, null, ast); } else { - TypeScript.Debug.assert(ast.kind() != 11 /* IdentifierName */ && ast.kind() != 212 /* MemberAccessExpression */); - var resolvedSymbol = this.resolveAST(ast, false, context); + TypeScript.Debug.assert(ast.kind() !== 11 /* IdentifierName */ && ast.kind() !== 212 /* MemberAccessExpression */); + resolvedSymbol = this.resolveAST(ast, false, context); } - if (decl.kind == 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.anyDeclHasFlag(8388608 /* PropertyParameter */ | 67108864 /* ConstructorParameter */)) { + if (decl.kind === 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.anyDeclHasFlag(8388608 /* PropertyParameter */ | 67108864 /* ConstructorParameter */)) { symbol.type = resolvedSymbol.type; symbol.setResolved(); } @@ -39480,23 +40313,25 @@ var TypeScript; return symbol; }; + PullTypeResolver.prototype.resolveOtherDecl = function (otherDecl, context) { + var astForOtherDecl = this.getASTForDecl(otherDecl); + var moduleDecl = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(astForOtherDecl); + if (TypeScript.ASTHelpers.isAnyNameOfModule(moduleDecl, astForOtherDecl)) { + this.resolveSingleModuleDeclaration(moduleDecl, astForOtherDecl, context); + } else { + this.resolveAST(astForOtherDecl, false, context); + } + }; + PullTypeResolver.prototype.resolveOtherDeclarations = function (astName, context) { + var _this = this; var resolvedDecl = this.semanticInfoChain.getDeclForAST(astName); var symbol = resolvedDecl.getSymbol(); var allDecls = symbol.getDeclarations(); - for (var i = 0; i < allDecls.length; i++) { - var currentDecl = allDecls[i]; - var astForCurrentDecl = this.getASTForDecl(currentDecl); - if (astForCurrentDecl != astName) { - var moduleDecl = TypeScript.getEnclosingModuleDeclaration(astForCurrentDecl); - if (TypeScript.isAnyNameOfModule(moduleDecl, astForCurrentDecl)) { - this.resolveSingleModuleDeclaration(moduleDecl, astForCurrentDecl, context); - } else { - this.resolveAST(astForCurrentDecl, false, context); - } - } - } + this.inResolvingOtherDeclsWalker.walkOtherPullDecls(resolvedDecl, symbol.getDeclarations(), function (otherDecl) { + return _this.resolveOtherDecl(otherDecl, context); + }); }; PullTypeResolver.prototype.resolveSourceUnit = function (sourceUnit, context) { @@ -39515,9 +40350,26 @@ var TypeScript; }; PullTypeResolver.prototype.typeCheckSourceUnit = function (sourceUnit, context) { + var _this = this; this.setTypeChecked(sourceUnit, context); this.resolveAST(sourceUnit.moduleElements, false, context); + + this.typeCheckCallBacks.push(function (context) { + return _this.verifyUniquenessOfImportNamesInSourceUnit(sourceUnit); + }); + }; + + PullTypeResolver.prototype.verifyUniquenessOfImportNamesInSourceUnit = function (sourceUnit) { + var _this = this; + var enclosingDecl = this.semanticInfoChain.getDeclForAST(sourceUnit); + + var doesImportNameExistInOtherFiles = function (name) { + var importSymbol = _this.semanticInfoChain.findTopLevelSymbol(name, 128 /* TypeAlias */, null); + return importSymbol && importSymbol.isAlias(); + }; + + this.checkUniquenessOfImportNames([enclosingDecl], doesImportNameExistInOtherFiles); }; PullTypeResolver.prototype.resolveEnumDeclaration = function (ast, context) { @@ -39552,13 +40404,18 @@ var TypeScript; }; PullTypeResolver.prototype.typeCheckEnumDeclaration = function (ast, context) { + var _this = this; this.setTypeChecked(ast, context); this.resolveAST(ast.enumElements, false, context); var containerDecl = this.semanticInfoChain.getDeclForAST(ast); this.validateVariableDeclarationGroups(containerDecl, context); - if (!TypeScript.enumIsElided(ast)) { + this.typeCheckCallBacks.push(function (context) { + return _this.checkInitializersInEnumDeclarations(containerDecl, context); + }); + + if (!TypeScript.ASTHelpers.enumIsElided(ast)) { this.checkNameForCompilerGeneratedDeclarationCollision(ast, true, ast.identifier, context); } }; @@ -39567,6 +40424,34 @@ var TypeScript; this.checkThisCaptureVariableCollides(ast, true, context); }; + PullTypeResolver.prototype.checkInitializersInEnumDeclarations = function (decl, context) { + var symbol = decl.getSymbol(); + + var declarations = symbol.getDeclarations(); + if (decl !== declarations[0]) { + return; + } + + var seenEnumDeclWithNoFirstMember = false; + for (var i = 0; i < declarations.length; ++i) { + var currentDecl = declarations[i]; + + var ast = currentDecl.ast(); + if (ast.enumElements.nonSeparatorCount() === 0) { + continue; + } + + var firstVariable = ast.enumElements.nonSeparatorAt(0); + if (!firstVariable.equalsValueClause) { + if (!seenEnumDeclWithNoFirstMember) { + seenEnumDeclWithNoFirstMember = true; + } else { + this.semanticInfoChain.addDiagnosticFromAST(firstVariable, TypeScript.DiagnosticCode.In_enums_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_the_first_enum_element); + } + } + } + }; + PullTypeResolver.prototype.resolveModuleDeclaration = function (ast, context) { var result; @@ -39614,7 +40499,7 @@ var TypeScript; this.resolveDeclaredSymbol(instanceSymbol, context); } - var isLastName = TypeScript.isLastNameOfModule(moduleDeclAST, moduleDeclNameAST); + var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDeclAST, moduleDeclNameAST); if (isLastName) { this.resolveFirstExportAssignmentStatement(moduleDeclAST.moduleElements, context); } else if (sourceUnitAST) { @@ -39633,7 +40518,7 @@ var TypeScript; PullTypeResolver.prototype.resolveFirstExportAssignmentStatement = function (moduleElements, context) { for (var i = 0, n = moduleElements.childCount(); i < n; i++) { var moduleElement = moduleElements.childAt(i); - if (moduleElement.kind() == 134 /* ExportAssignment */) { + if (moduleElement.kind() === 134 /* ExportAssignment */) { this.resolveExportAssignmentStatement(moduleElement, context); return; } @@ -39659,9 +40544,10 @@ var TypeScript; }; PullTypeResolver.prototype.typeCheckSingleModuleDeclaration = function (ast, astName, context) { + var _this = this; this.setTypeChecked(ast, context); - if (TypeScript.isLastNameOfModule(ast, astName)) { + if (TypeScript.ASTHelpers.isLastNameOfModule(ast, astName)) { this.resolveAST(ast.moduleElements, false, context); } @@ -39674,9 +40560,106 @@ var TypeScript; } } - if (!TypeScript.moduleIsElided(ast) && !ast.stringLiteral) { + if (!TypeScript.ASTHelpers.moduleIsElided(ast) && !ast.stringLiteral) { this.checkNameForCompilerGeneratedDeclarationCollision(astName, true, astName, context); } + + this.typeCheckCallBacks.push(function (context) { + return _this.verifyUniquenessOfImportNamesInModule(containerDecl); + }); + }; + + PullTypeResolver.prototype.verifyUniquenessOfImportNamesInModule = function (decl) { + var symbol = decl.getSymbol(); + if (!symbol) { + return; + } + + var decls = symbol.getDeclarations(); + + if (decls[0] !== decl) { + return; + } + + this.checkUniquenessOfImportNames(decls); + }; + + PullTypeResolver.prototype.checkUniquenessOfImportNames = function (decls, doesNameExistOutside) { + var _this = this; + var importDeclarationNames; + + for (var i = 0; i < decls.length; ++i) { + var childDecls = decls[i].getChildDecls(); + for (var j = 0; j < childDecls.length; ++j) { + var childDecl = childDecls[j]; + if (childDecl.kind === 128 /* TypeAlias */) { + importDeclarationNames = importDeclarationNames || TypeScript.createIntrinsicsObject(); + importDeclarationNames[childDecl.name] = true; + } + } + } + + if (!importDeclarationNames && !doesNameExistOutside) { + return; + } + + for (var i = 0; i < decls.length; ++i) { + this.scanVariableDeclarationGroups(decls[i], function (firstDeclInGroup) { + var nameConflict = importDeclarationNames && importDeclarationNames[firstDeclInGroup.name]; + if (!nameConflict) { + nameConflict = doesNameExistOutside && doesNameExistOutside(firstDeclInGroup.name); + if (nameConflict) { + importDeclarationNames = importDeclarationNames || TypeScript.createIntrinsicsObject(); + importDeclarationNames[firstDeclInGroup.name] = true; + } + } + + if (nameConflict) { + _this.semanticInfoChain.addDiagnosticFromAST(firstDeclInGroup.ast(), TypeScript.DiagnosticCode.Variable_declaration_cannot_have_the_same_name_as_an_import_declaration); + } + }); + } + }; + + PullTypeResolver.prototype.scanVariableDeclarationGroups = function (enclosingDecl, firstDeclHandler, subsequentDeclHandler) { + var declGroups = enclosingDecl.getVariableDeclGroups(); + + for (var i = 0; i < declGroups.length; i++) { + var firstSymbol = null; + var enclosingDeclForFirstSymbol = null; + + if (enclosingDecl.kind === 1 /* Script */ && declGroups[i].length) { + var name = declGroups[i][0].name; + var candidateSymbol = this.semanticInfoChain.findTopLevelSymbol(name, 512 /* Variable */, enclosingDecl); + if (candidateSymbol && candidateSymbol.isResolved) { + if (!candidateSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */)) { + firstSymbol = candidateSymbol; + } + } + } + + for (var j = 0; j < declGroups[i].length; j++) { + var decl = declGroups[i][j]; + + var name = decl.name; + + var symbol = decl.getSymbol(); + + if (j === 0) { + firstDeclHandler(decl); + if (!subsequentDeclHandler) { + break; + } + + if (!firstSymbol || !firstSymbol.type) { + firstSymbol = symbol; + continue; + } + } + + subsequentDeclHandler(decl, firstSymbol); + } + } }; PullTypeResolver.prototype.postTypeCheckModuleDeclaration = function (ast, context) { @@ -39684,12 +40667,12 @@ var TypeScript; }; PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (term) { - if (term.kind() == 11 /* IdentifierName */) { + if (term.kind() === 11 /* IdentifierName */) { return true; - } else if (term.kind() == 121 /* QualifiedName */) { + } else if (term.kind() === 121 /* QualifiedName */) { var binex = term; - if (binex.right.kind() == 11 /* IdentifierName */) { + if (binex.right.kind() === 11 /* IdentifierName */) { return true; } } @@ -39719,7 +40702,7 @@ var TypeScript; var enclosingDecl = this.getEnclosingDecl(typeDecl); var typeDeclSymbol = typeDecl.getSymbol(); var typeDeclIsClass = classOrInterface.kind() === 131 /* ClassDeclaration */; - var hasVisited = this.getSymbolForAST(classOrInterface, context) != null; + var hasVisited = this.getSymbolForAST(classOrInterface, context) !== null; if ((typeDeclSymbol.isResolved && hasVisited) || (typeDeclSymbol.inResolution && !context.isInBaseTypeResolution())) { return typeDeclSymbol; @@ -39728,13 +40711,6 @@ var TypeScript; var wasResolving = typeDeclSymbol.inResolution; typeDeclSymbol.startResolving(); - if (!typeDeclSymbol.isResolved) { - var typeDeclTypeParameters = typeDeclSymbol.getTypeParameters(); - for (var i = 0; i < typeDeclTypeParameters.length; i++) { - this.resolveDeclaredSymbol(typeDeclTypeParameters[i], context); - } - } - var typeRefDecls = typeDeclSymbol.getDeclarations(); for (var i = 0; i < typeRefDecls.length; i++) { @@ -39745,13 +40721,20 @@ var TypeScript; } } + if (!typeDeclSymbol.isResolved) { + var typeDeclTypeParameters = typeDeclSymbol.getTypeParameters(); + for (var i = 0; i < typeDeclTypeParameters.length; i++) { + this.resolveDeclaredSymbol(typeDeclTypeParameters[i], context); + } + } + var wasInBaseTypeResolution = context.startBaseTypeResolution(); if (!typeDeclIsClass && !hasVisited) { typeDeclSymbol.resetKnownBaseTypeCount(); } - var extendsClause = TypeScript.getExtendsHeritageClause(heritageClauses); + var extendsClause = TypeScript.ASTHelpers.getExtendsHeritageClause(heritageClauses); if (extendsClause) { for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < extendsClause.typeNames.nonSeparatorCount(); i = typeDeclSymbol.getKnownBaseTypeCount()) { typeDeclSymbol.incrementKnownBaseCount(); @@ -39775,7 +40758,7 @@ var TypeScript; } } - var implementsClause = TypeScript.getImplementsHeritageClause(heritageClauses); + var implementsClause = TypeScript.ASTHelpers.getImplementsHeritageClause(heritageClauses); if (implementsClause && typeDeclIsClass) { var extendsCount = extendsClause ? extendsClause.typeNames.nonSeparatorCount() : 0; for (var i = typeDeclSymbol.getKnownBaseTypeCount(); ((i - extendsCount) >= 0) && ((i - extendsCount) < implementsClause.typeNames.nonSeparatorCount()); i = typeDeclSymbol.getKnownBaseTypeCount()) { @@ -39801,7 +40784,7 @@ var TypeScript; typeDeclSymbol.inResolution = false; this.typeCheckCallBacks.push(function (context) { - if (classOrInterface.kind() == 131 /* ClassDeclaration */) { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { _this.resolveClassDeclaration(classOrInterface, context); } else { _this.resolveInterfaceDeclaration(classOrInterface, context); @@ -39811,25 +40794,6 @@ var TypeScript; return typeDeclSymbol; } - if (!typeDeclSymbol.isResolved) { - if (!typeDeclIsClass) { - var callSignatures = typeDeclSymbol.getCallSignatures(); - for (var i = 0; i < callSignatures.length; i++) { - this.resolveDeclaredSymbol(callSignatures[i], context); - } - - var constructSignatures = typeDeclSymbol.getConstructSignatures(); - for (var i = 0; i < constructSignatures.length; i++) { - this.resolveDeclaredSymbol(constructSignatures[i], context); - } - - var indexSignatures = typeDeclSymbol.getIndexSignatures(); - for (var i = 0; i < indexSignatures.length; i++) { - this.resolveDeclaredSymbol(indexSignatures[i], context); - } - } - } - this.setSymbolForAST(name, typeDeclSymbol, context); this.setSymbolForAST(classOrInterface, typeDeclSymbol, context); @@ -39841,6 +40805,7 @@ var TypeScript; PullTypeResolver.prototype.resolveClassDeclaration = function (classDeclAST, context) { var classDecl = this.semanticInfoChain.getDeclForAST(classDeclAST); var classDeclSymbol = classDecl.getSymbol(); + if (!classDeclSymbol.isResolved) { this.resolveReferenceTypeDeclaration(classDeclAST, classDeclAST.identifier, classDeclAST.heritageClauses, context); @@ -39869,15 +40834,9 @@ var TypeScript; if (!parentConstructSignatures.length) { parentConstructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); parentConstructSignature.returnType = parentType; - parentConstructorType.addConstructSignature(parentConstructSignature); + parentConstructSignature.addTypeParametersFromReturnType(); + parentConstructorType.appendConstructSignature(parentConstructSignature); parentConstructSignature.addDeclaration(parentType.getDeclarations()[0]); - - var parentTypeParameters = parentConstructorType.getTypeParameters(); - - for (var i = 0; i < parentTypeParameters.length; i++) { - parentConstructSignature.addTypeParameter(parentTypeParameters[i]); - } - parentConstructSignatures = [parentConstructSignature]; } @@ -39885,33 +40844,23 @@ var TypeScript; parentConstructSignature = parentConstructSignatures[i]; parentParameters = parentConstructSignature.parameters; - constructorSignature = parentConstructSignature.isDefinition() ? new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */) : new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */, parentConstructSignature.isDefinition()); constructorSignature.returnType = classDeclSymbol; + constructorSignature.addTypeParametersFromReturnType(); for (var j = 0; j < parentParameters.length; j++) { constructorSignature.addParameter(parentParameters[j], parentParameters[j].isOptional); } - var typeParameters = constructorTypeSymbol.getTypeParameters(); - - for (var j = 0; j < typeParameters.length; j++) { - constructorSignature.addTypeParameter(typeParameters[j]); - } - - constructorTypeSymbol.addConstructSignature(constructorSignature); + constructorTypeSymbol.appendConstructSignature(constructorSignature); constructorSignature.addDeclaration(classDecl); } } else { constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); constructorSignature.returnType = classDeclSymbol; - constructorTypeSymbol.addConstructSignature(constructorSignature); + constructorSignature.addTypeParametersFromReturnType(); + constructorTypeSymbol.appendConstructSignature(constructorSignature); constructorSignature.addDeclaration(classDecl); - - var typeParameters = constructorTypeSymbol.getTypeParameters(); - - for (var i = 0; i < typeParameters.length; i++) { - constructorSignature.addTypeParameter(typeParameters[i]); - } } } @@ -39944,13 +40893,23 @@ var TypeScript; PullTypeResolver.prototype.typeCheckTypeParametersOfTypeDeclaration = function (classOrInterface, context) { var _this = this; - var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); - var typeDeclSymbol = typeDecl.getSymbol(); - var typeDeclTypeParameters = typeDeclSymbol.getTypeParameters(); - for (var i = 0; i < typeDeclTypeParameters.length; i++) { - this.checkSymbolPrivacy(typeDeclSymbol, typeDeclTypeParameters[i], function (symbol) { - return _this.typeParameterOfTypeDeclarationPrivacyErrorReporter(classOrInterface, i, typeDeclTypeParameters[i], symbol, context); - }); + var typeParametersList = classOrInterface.kind() == 131 /* ClassDeclaration */ ? classOrInterface.typeParameterList : classOrInterface.typeParameterList; + + if (typeParametersList) { + var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); + var typeDeclSymbol = typeDecl.getSymbol(); + + for (var i = 0; i < typeParametersList.typeParameters.nonSeparatorCount(); i++) { + var typeParameterAST = typeParametersList.typeParameters.nonSeparatorAt(i); + this.resolveTypeParameterDeclaration(typeParameterAST, context); + + var typeParameterDecl = this.semanticInfoChain.getDeclForAST(typeParameterAST); + var typeParameterSymbol = typeParameterDecl.getSymbol(); + + this.checkSymbolPrivacy(typeDeclSymbol, typeParameterSymbol, function (symbol) { + return _this.typeParameterOfTypeDeclarationPrivacyErrorReporter(classOrInterface, typeParameterAST, typeParameterSymbol, symbol, context); + }); + } } }; @@ -39969,6 +40928,8 @@ var TypeScript; if (!classDeclSymbol.hasBaseTypeConflict()) { this.typeCheckMembersAgainstIndexer(classDeclSymbol, classDecl, context); } + + this.checkTypeForDuplicateIndexSignatures(classDeclSymbol); }; PullTypeResolver.prototype.postTypeCheckClassDeclaration = function (classDeclAST, context) { @@ -40025,6 +40986,88 @@ var TypeScript; if (!interfaceDeclSymbol.hasBaseTypeConflict()) { this.typeCheckMembersAgainstIndexer(interfaceDeclSymbol, interfaceDecl, context); } + + var allInterfaceDecls = interfaceDeclSymbol.getDeclarations(); + if (interfaceDecl === allInterfaceDecls[allInterfaceDecls.length - 1]) { + this.checkTypeForDuplicateIndexSignatures(interfaceDeclSymbol); + } + + if (!this.checkInterfaceDeclForIdenticalTypeParameters(interfaceDeclAST, context)) { + this.semanticInfoChain.addDiagnosticFromAST(interfaceDeclAST.identifier, TypeScript.DiagnosticCode.All_declarations_of_an_interface_must_have_identical_type_parameters); + } + }; + + PullTypeResolver.prototype.checkInterfaceDeclForIdenticalTypeParameters = function (interfaceDeclAST, context) { + var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); + var interfaceDeclSymbol = interfaceDecl.getSymbol(); + + if (!interfaceDeclSymbol.isGeneric()) { + return true; + } + + var firstInterfaceDecl = interfaceDeclSymbol.getDeclarations()[0]; + if (firstInterfaceDecl == interfaceDecl) { + return true; + } + + var typeParameters = interfaceDecl.getTypeParameters(); + var firstInterfaceDeclTypeParameters = firstInterfaceDecl.getTypeParameters(); + + if (typeParameters.length != firstInterfaceDeclTypeParameters.length) { + return false; + } + + for (var i = 0; i < typeParameters.length; i++) { + var typeParameter = typeParameters[i]; + var firstInterfaceDeclTypeParameter = firstInterfaceDeclTypeParameters[i]; + + if (typeParameter.name != firstInterfaceDeclTypeParameter.name) { + return false; + } + + var typeParameterSymbol = typeParameter.getSymbol(); + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter); + var firstInterfaceDeclTypeParameterAST = this.semanticInfoChain.getASTForDecl(firstInterfaceDeclTypeParameter); + + if (!!typeParameterAST.constraint != !!firstInterfaceDeclTypeParameterAST.constraint) { + return false; + } + + if (typeParameterAST.constraint) { + var typeParameterConstraint = this.resolveAST(typeParameterAST.constraint, false, context); + if (!this.typesAreIdenticalWithNewEnclosingTypes(typeParameterConstraint, typeParameterSymbol.getConstraint(), context)) { + return false; + } + } + } + + return true; + }; + + PullTypeResolver.prototype.checkTypeForDuplicateIndexSignatures = function (enclosingTypeSymbol) { + var indexSignatures = enclosingTypeSymbol.getOwnIndexSignatures(); + var firstStringIndexer = null; + var firstNumberIndexer = null; + for (var i = 0; i < indexSignatures.length; i++) { + var currentIndexer = indexSignatures[i]; + var currentParameterType = currentIndexer.parameters[0].type; + TypeScript.Debug.assert(currentParameterType); + if (currentParameterType === this.semanticInfoChain.stringTypeSymbol) { + if (firstStringIndexer) { + this.semanticInfoChain.addDiagnosticFromAST(currentIndexer.getDeclarations()[0].ast(), TypeScript.DiagnosticCode.Duplicate_string_index_signature, null, [this.semanticInfoChain.locationFromAST(firstStringIndexer.getDeclarations()[0].ast())]); + return; + } else { + firstStringIndexer = currentIndexer; + } + } else if (currentParameterType === this.semanticInfoChain.numberTypeSymbol) { + if (firstNumberIndexer) { + this.semanticInfoChain.addDiagnosticFromAST(currentIndexer.getDeclarations()[0].ast(), TypeScript.DiagnosticCode.Duplicate_number_index_signature, null, [this.semanticInfoChain.locationFromAST(firstNumberIndexer.getDeclarations()[0].ast())]); + return; + } else { + firstNumberIndexer = currentIndexer; + } + } + } }; PullTypeResolver.prototype.filterSymbol = function (symbol, kind, enclosingDecl, context) { @@ -40039,7 +41082,7 @@ var TypeScript; var alias = symbol; if (kind & 164 /* SomeContainer */) { return alias.getExportAssignedContainerSymbol(); - } else if (kind & 58728539 /* SomeType */) { + } else if (kind & 58728795 /* SomeType */) { return alias.getExportAssignedTypeSymbol(); } else if (kind & 68147712 /* SomeValue */) { return alias.getExportAssignedValueSymbol(); @@ -40050,7 +41093,7 @@ var TypeScript; }; PullTypeResolver.prototype.getMemberSymbolOfKind = function (symbolName, kind, pullTypeSymbol, enclosingDecl, context) { - var memberSymbol = this.getMemberSymbol(symbolName, kind, pullTypeSymbol); + var memberSymbol = this.getNamedPropertySymbol(symbolName, kind, pullTypeSymbol); return { symbol: this.filterSymbol(memberSymbol, kind, enclosingDecl, context), @@ -40074,11 +41117,11 @@ var TypeScript; var acceptableAlias = true; if (containerSymbol) { - acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) != 0; + acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; aliasSymbol = memberSymbol.aliasSymbol; } - if (!acceptableAlias && containerSymbol && containerSymbol.kind == 128 /* TypeAlias */) { + if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { this.resolveDeclaredSymbol(containerSymbol, context); var aliasedAssignedValue = containerSymbol.getExportAssignedValueSymbol(); var aliasedAssignedType = containerSymbol.getExportAssignedTypeSymbol(); @@ -40109,7 +41152,7 @@ var TypeScript; } if (!typeSymbol) { - memberSymbol = this.getMemberSymbolOfKind(rhsName, 58728539 /* SomeType */, moduleTypeSymbol, enclosingDecl, context); + memberSymbol = this.getMemberSymbolOfKind(rhsName, 58728795 /* SomeType */, moduleTypeSymbol, enclosingDecl, context); typeSymbol = memberSymbol.symbol; if (typeSymbol && memberSymbol.aliasSymbol) { aliasSymbol = memberSymbol.aliasSymbol; @@ -40134,12 +41177,12 @@ var TypeScript; }; PullTypeResolver.prototype.resolveModuleReference = function (importDecl, moduleNameExpr, enclosingDecl, context, declPath) { - TypeScript.Debug.assert(moduleNameExpr.kind() == 121 /* QualifiedName */ || moduleNameExpr.kind() == 11 /* IdentifierName */ || moduleNameExpr.kind() === 14 /* StringLiteral */, "resolving module reference should always be either name or member reference"); + TypeScript.Debug.assert(moduleNameExpr.kind() === 121 /* QualifiedName */ || moduleNameExpr.kind() === 11 /* IdentifierName */ || moduleNameExpr.kind() === 14 /* StringLiteral */, "resolving module reference should always be either name or member reference"); var moduleSymbol = null; var moduleName; - if (moduleNameExpr.kind() == 121 /* QualifiedName */) { + if (moduleNameExpr.kind() === 121 /* QualifiedName */) { var dottedNameAST = moduleNameExpr; var moduleContainer = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); if (moduleContainer) { @@ -40161,6 +41204,8 @@ var TypeScript; this.semanticInfoChain.setSymbolForAST(moduleNameExpr, moduleSymbol); if (resolvedModuleNameSymbol.isAlias()) { this.semanticInfoChain.setAliasSymbolForAST(moduleNameExpr, resolvedModuleNameSymbol); + var importDeclSymbol = importDecl.getSymbol(); + importDeclSymbol.addLinkedAliasSymbol(resolvedModuleNameSymbol); } } else { this.semanticInfoChain.addDiagnosticFromAST(moduleNameExpr, TypeScript.DiagnosticCode.Unable_to_resolve_module_reference_0, [valueText]); @@ -40181,6 +41226,7 @@ var TypeScript; var declPath = enclosingDecl.getParentPath(); var aliasedType = null; + var importDeclSymbol = importDecl.getSymbol(); if (aliasExpr.kind() === 11 /* IdentifierName */ || aliasExpr.kind() === 14 /* StringLiteral */) { var moduleSymbol = this.resolveModuleReference(importDecl, aliasExpr, enclosingDecl, context, declPath); @@ -40192,19 +41238,17 @@ var TypeScript; var valueSymbol = this.getSymbolFromDeclPath(moduleName, declPath, 68147712 /* SomeValue */); var instanceSymbol = aliasedType.getInstanceSymbol(); - if (valueSymbol && (instanceSymbol != valueSymbol || valueSymbol.type == aliasedType)) { + if (valueSymbol && (instanceSymbol != valueSymbol || valueSymbol.type === aliasedType)) { var text = aliasExpr.kind() === 11 /* IdentifierName */ ? aliasExpr.text() : aliasExpr.text(); context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(aliasExpr, TypeScript.DiagnosticCode.Internal_module_reference_0_in_import_declaration_does_not_reference_module_instance_for_1, [text, moduleSymbol.type.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); } else { - var importDeclSymbol = importDecl.getSymbol(); importDeclSymbol.setAssignedValueSymbol(valueSymbol); } } } else { - aliasedType = this.semanticInfoChain.anyTypeSymbol; + aliasedType = this.getNewErrorTypeSymbol(); } - } else if (aliasExpr.kind() == 121 /* QualifiedName */) { - var importDeclSymbol = importDecl.getSymbol(); + } else if (aliasExpr.kind() === 121 /* QualifiedName */) { var dottedNameAST = aliasExpr; var moduleSymbol = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); if (moduleSymbol) { @@ -40214,14 +41258,13 @@ var TypeScript; importDeclSymbol.setAssignedTypeSymbol(identifierResolution.typeSymbol); importDeclSymbol.setAssignedContainerSymbol(identifierResolution.containerSymbol); this.semanticInfoChain.setAliasSymbolForAST(moduleReference, identifierResolution.aliasSymbol); - if (identifierResolution.valueSymbol) { - importDeclSymbol.setIsUsedAsValue(true); - } return null; } } + } - importDeclSymbol.setAssignedTypeSymbol(this.semanticInfoChain.anyTypeSymbol); + if (!aliasedType) { + importDeclSymbol.setAssignedTypeSymbol(this.getNewErrorTypeSymbol()); } return aliasedType; @@ -40249,7 +41292,7 @@ var TypeScript; if (!aliasedType) { var path = importStatementAST.moduleReference.stringLiteral.text(); this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Unable_to_resolve_external_module_0, [path]); - aliasedType = this.semanticInfoChain.anyTypeSymbol; + aliasedType = this.getNewErrorTypeSymbol(); } } else { aliasedType = this.resolveInternalModuleReference(importStatementAST, context); @@ -40258,9 +41301,9 @@ var TypeScript; if (aliasedType) { if (!aliasedType.isContainer()) { this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Module_cannot_be_aliased_to_a_non_module_type); - aliasedType = this.semanticInfoChain.anyTypeSymbol; - } else if (aliasedType.getExportAssignedValueSymbol()) { - importDeclSymbol.setIsUsedAsValue(true); + if (!aliasedType.isError()) { + aliasedType = this.getNewErrorTypeSymbol(); + } } if (aliasedType.isContainer()) { @@ -40277,6 +41320,14 @@ var TypeScript; this.resolveDeclaredSymbol(importDeclSymbol.assignedType(), context); this.resolveDeclaredSymbol(importDeclSymbol.assignedContainer(), context); + if (aliasedType && importDeclSymbol.anyDeclHasFlag(1 /* Exported */)) { + importDeclSymbol.setIsUsedInExportedAlias(); + + if (aliasedType.isContainer() && aliasedType.getExportAssignedValueSymbol()) { + importDeclSymbol.setIsUsedAsValue(); + } + } + if (this.canTypeCheckAST(importStatementAST, context)) { this.typeCheckImportDeclaration(importStatementAST, context); } @@ -40299,7 +41350,7 @@ var TypeScript; var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); if (enclosingDecl.kind === 32 /* DynamicModule */) { - var ast = TypeScript.getEnclosingModuleDeclaration(this.getASTForDecl(enclosingDecl)); + var ast = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(this.getASTForDecl(enclosingDecl)); if (ast && ast.kind() === 130 /* ModuleDeclaration */) { if (TypeScript.isRelative(modPath)) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name)); @@ -40312,7 +41363,7 @@ var TypeScript; if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); var container = containerSymbol ? containerSymbol.getContainer() : null; - if (container && container.kind == 32 /* DynamicModule */) { + if (container && container.kind === 32 /* DynamicModule */) { checkPrivacy = true; } } else { @@ -40330,7 +41381,7 @@ var TypeScript; context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); }); - if (typeSymbol != containerSymbol) { + if (typeSymbol !== containerSymbol) { this.checkSymbolPrivacy(importDeclSymbol, typeSymbol, function (symbol) { var messageCode = symbol.isContainer() && !symbol.isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_type_that_has_or_is_using_private_type_1; @@ -40348,14 +41399,18 @@ var TypeScript; } } - if (getCompilerReservedName(importStatementAST.identifier)) { - this.postTypeCheckWorkitems.push(importStatementAST); - } + this.checkNameForCompilerGeneratedDeclarationCollision(importStatementAST, true, importStatementAST.identifier, context); }; PullTypeResolver.prototype.postTypeCheckImportDeclaration = function (importStatementAST, context) { - if (TypeScript.importDeclarationIsElided(importStatementAST, this.semanticInfoChain)) { - this.checkNameForCompilerGeneratedDeclarationCollision(importStatementAST, true, importStatementAST.identifier, context, true); + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var importSymbol = importDecl.getSymbol(); + + var isUsedAsValue = importSymbol.isUsedAsValue(); + var hasAssignedValue = importStatementAST.moduleReference.kind() !== 245 /* ExternalModuleReference */ && importSymbol.getExportAssignedValueSymbol() !== null; + + if (isUsedAsValue || hasAssignedValue) { + this.checkThisCaptureVariableCollides(importStatementAST, true, context); } }; @@ -40384,10 +41439,10 @@ var TypeScript; var acceptableAlias = true; if (containerSymbol) { - acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) != 0; + acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; } - if (!acceptableAlias && containerSymbol && containerSymbol.kind == 128 /* TypeAlias */) { + if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { this.resolveDeclaredSymbol(containerSymbol, context); var aliasSymbol = containerSymbol; @@ -40399,7 +41454,10 @@ var TypeScript; valueSymbol = aliasedAssignedValue; typeSymbol = aliasedAssignedType; containerSymbol = aliasedAssignedContainer; - aliasSymbol.setTypeUsedExternally(true); + aliasSymbol.setTypeUsedExternally(); + if (valueSymbol) { + aliasSymbol.setIsUsedAsValue(); + } acceptableAlias = true; } } @@ -40413,7 +41471,7 @@ var TypeScript; valueSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); } if (!typeSymbol) { - typeSymbol = this.getSymbolFromDeclPath(id, declPath, 58728539 /* SomeType */); + typeSymbol = this.getSymbolFromDeclPath(id, declPath, 58728795 /* SomeType */); } if (!valueSymbol && !typeSymbol && !containerSymbol) { @@ -40477,28 +41535,32 @@ var TypeScript; var paramSymbol = paramDecl.getSymbol(); if (argDeclAST.typeAnnotation) { - var typeRef = this.resolveTypeReference(TypeScript.getType(argDeclAST), context); + var typeRef = this.resolveTypeReference(TypeScript.ASTHelpers.getType(argDeclAST), context); if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { - var diagnostic = context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); typeRef = this.getNewErrorTypeSymbol(); } context.setTypeInContext(paramSymbol, typeRef); } else { - if (paramSymbol.isVarArg && paramSymbol.type) { + if (paramSymbol.isVarArg) { if (this.cachedArrayInterfaceType()) { - context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [paramSymbol.type])); + context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); } else { - context.setTypeInContext(paramSymbol, paramSymbol.type); + context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); } } else { context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); - - if (this.compilationSettings.noImplicitAny()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_function_type_implicitly_has_an_any_type, [argDeclAST.identifier.text()])); - } } + + if (this.compilationSettings.noImplicitAny()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_function_type_implicitly_has_an_any_type, [argDeclAST.identifier.text()])); + } + } + + if (TypeScript.hasFlag(paramDecl.flags, 128 /* Optional */) && argDeclAST.equalsValueClause && isTypesOnlyLocation(argDeclAST)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Default_arguments_are_only_allowed_in_implementation)); } paramSymbol.setResolved(); @@ -40521,22 +41583,29 @@ var TypeScript; contextualType = typeRef || contextualType; } if (contextualType) { + if (context.isInferentiallyTyping()) { + contextualType = context.fixAllTypeParametersReferencedByType(contextualType, this); + } context.setTypeInContext(paramSymbol, contextualType); - } else if (paramSymbol.isVarArg && this.cachedArrayInterfaceType()) { - context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); + } else if (paramSymbol.isVarArg) { + if (this.cachedArrayInterfaceType()) { + context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); + } else { + context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); + } isImplicitAny = true; } var canTypeCheckAST = this.canTypeCheckAST(argDeclAST, context); if (equalsValueClause && (canTypeCheckAST || !contextualType)) { if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); + context.propagateContextualType(contextualType); } - var initExprSymbol = this.resolveAST(equalsValueClause, contextualType != null, context); + var initExprSymbol = this.resolveAST(equalsValueClause, contextualType !== null, context); if (contextualType) { - context.popContextualType(); + context.popAnyContextualType(); } if (!initExprSymbol || !initExprSymbol.type) { @@ -40548,7 +41617,7 @@ var TypeScript; } else { var initTypeSymbol = this.getInstanceTypeForAssignment(argDeclAST, initExprSymbol.type, context); if (!contextualType) { - context.setTypeInContext(paramSymbol, this.widenType(initTypeSymbol, equalsValueClause, context)); + context.setTypeInContext(paramSymbol, initTypeSymbol.widenedType(this, equalsValueClause, context)); isImplicitAny = initTypeSymbol !== paramSymbol.type; } else { var comparisonInfo = new TypeComparisonInfo(); @@ -40588,42 +41657,31 @@ var TypeScript; paramSymbol.setResolved(); }; - PullTypeResolver.prototype.checkNameForCompilerGeneratedDeclarationCollision = function (astWithName, isDeclaration, name, context, immediateThisCheck) { + PullTypeResolver.prototype.checkNameForCompilerGeneratedDeclarationCollision = function (astWithName, isDeclaration, name, context) { var compilerReservedName = getCompilerReservedName(name); - if (compilerReservedName) { - switch (compilerReservedName) { - case 1 /* _this */: - if (immediateThisCheck) { - this.checkThisCaptureVariableCollides(astWithName, isDeclaration, context); - } else { - this.postTypeCheckWorkitems.push(astWithName); - } - return; + switch (compilerReservedName) { + case 1 /* _this */: + this.postTypeCheckWorkitems.push(astWithName); + return; - case 2 /* _super */: - this.checkSuperCaptureVariableCollides(astWithName, isDeclaration, context); - return; + case 2 /* _super */: + this.checkSuperCaptureVariableCollides(astWithName, isDeclaration, context); + return; - case 3 /* arguments */: - this.checkArgumentsCollides(astWithName, context); - return; + case 3 /* arguments */: + this.checkArgumentsCollides(astWithName, context); + return; - case 4 /* _i */: - if (isDeclaration) { - this.checkIndexOfRestArgumentInitializationCollides(astWithName, context); - } - return; + case 4 /* _i */: + this.checkIndexOfRestArgumentInitializationCollides(astWithName, isDeclaration, context); + return; - case 5 /* require */: - case 6 /* exports */: - if (isDeclaration) { - this.checkExternalModuleRequireExportsCollides(astWithName, name, context); - } - return; - - default: - TypeScript.Debug.fail("Unknown compiler reserved name: " + name.text()); - } + case 5 /* require */: + case 6 /* exports */: + if (isDeclaration) { + this.checkExternalModuleRequireExportsCollides(astWithName, name, context); + } + return; } }; @@ -40631,16 +41689,16 @@ var TypeScript; var enclosingAST = this.getASTForDecl(someFunctionDecl); var nodeType = enclosingAST.kind(); - if (nodeType == 129 /* FunctionDeclaration */) { + if (nodeType === 129 /* FunctionDeclaration */) { var functionDeclaration = enclosingAST; - return !TypeScript.hasFlag(someFunctionDecl.kind == 65536 /* Method */ ? someFunctionDecl.getParentDecl().flags : someFunctionDecl.flags, 8 /* Ambient */) && functionDeclaration.block && TypeScript.lastParameterIsRest(functionDeclaration.callSignature.parameterList); + return !TypeScript.hasFlag(someFunctionDecl.kind === 65536 /* Method */ ? someFunctionDecl.getParentDecl().flags : someFunctionDecl.flags, 8 /* Ambient */) && functionDeclaration.block && TypeScript.lastParameterIsRest(functionDeclaration.callSignature.parameterList); } else if (nodeType === 135 /* MemberFunctionDeclaration */) { var memberFunction = enclosingAST; - return !TypeScript.hasFlag(someFunctionDecl.kind == 65536 /* Method */ ? someFunctionDecl.getParentDecl().flags : someFunctionDecl.flags, 8 /* Ambient */) && memberFunction.block && TypeScript.lastParameterIsRest(memberFunction.callSignature.parameterList); - } else if (nodeType == 137 /* ConstructorDeclaration */) { + return !TypeScript.hasFlag(someFunctionDecl.kind === 65536 /* Method */ ? someFunctionDecl.getParentDecl().flags : someFunctionDecl.flags, 8 /* Ambient */) && memberFunction.block && TypeScript.lastParameterIsRest(memberFunction.callSignature.parameterList); + } else if (nodeType === 137 /* ConstructorDeclaration */) { var constructorDeclaration = enclosingAST; - return !TypeScript.hasFlag(someFunctionDecl.getParentDecl().flags, 8 /* Ambient */) && constructorDeclaration.block && TypeScript.lastParameterIsRest(constructorDeclaration.parameterList); - } else if (nodeType == 218 /* ParenthesizedArrowFunctionExpression */) { + return !TypeScript.hasFlag(someFunctionDecl.getParentDecl().flags, 8 /* Ambient */) && constructorDeclaration.block && TypeScript.lastParameterIsRest(constructorDeclaration.callSignature.parameterList); + } else if (nodeType === 218 /* ParenthesizedArrowFunctionExpression */) { var arrowFunctionExpression = enclosingAST; return TypeScript.lastParameterIsRest(arrowFunctionExpression.callSignature.parameterList); } else if (nodeType === 222 /* FunctionExpression */) { @@ -40652,7 +41710,7 @@ var TypeScript; }; PullTypeResolver.prototype.checkArgumentsCollides = function (ast, context) { - if (ast.kind() == 242 /* Parameter */) { + if (ast.kind() === 242 /* Parameter */) { var enclosingDecl = this.getEnclosingDeclForAST(ast); if (TypeScript.hasFlag(enclosingDecl.kind, 1032192 /* SomeFunction */)) { if (this.hasRestParameterCodeGen(enclosingDecl)) { @@ -40662,12 +41720,33 @@ var TypeScript; } }; - PullTypeResolver.prototype.checkIndexOfRestArgumentInitializationCollides = function (ast, context) { - if (ast.kind() == 242 /* Parameter */) { + PullTypeResolver.prototype.checkIndexOfRestArgumentInitializationCollides = function (ast, isDeclaration, context) { + if (!isDeclaration || ast.kind() === 242 /* Parameter */) { var enclosingDecl = this.getEnclosingDeclForAST(ast); - if (TypeScript.hasFlag(enclosingDecl.kind, 1032192 /* SomeFunction */)) { - if (this.hasRestParameterCodeGen(enclosingDecl)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter)); + var declPath = isDeclaration ? [enclosingDecl] : (enclosingDecl ? enclosingDecl.getParentPath() : []); + var resolvedSymbol = null; + var resolvedSymbolContainer; + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + if (!isDeclaration) { + if (!resolvedSymbol) { + resolvedSymbol = this.resolveNameExpression(ast, context); + if (resolvedSymbol.isError()) { + return; + } + + resolvedSymbolContainer = resolvedSymbol.getContainer(); + } + + if (resolvedSymbolContainer && TypeScript.ArrayUtilities.contains(resolvedSymbolContainer.getDeclarations(), decl)) { + break; + } + } + + if (TypeScript.hasFlag(decl.kind, 1032192 /* SomeFunction */)) { + if (this.hasRestParameterCodeGen(decl)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter : TypeScript.DiagnosticCode.Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter)); + } } } } @@ -40676,12 +41755,12 @@ var TypeScript; PullTypeResolver.prototype.checkExternalModuleRequireExportsCollides = function (ast, name, context) { var enclosingDecl = this.getEnclosingDeclForAST(ast); - var enclosingModule = TypeScript.getEnclosingModuleDeclaration(name); - if (TypeScript.isAnyNameOfModule(enclosingModule, name)) { + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(name); + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, name)) { enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); } - if (enclosingDecl && enclosingDecl.kind == 32 /* DynamicModule */) { + if (enclosingDecl && enclosingDecl.kind === 32 /* DynamicModule */) { var decl = this.semanticInfoChain.getDeclForAST(ast); if (!TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { @@ -40733,6 +41812,7 @@ var TypeScript; var objectTypeSymbol = objectTypeDecl.getSymbol(); this.typeCheckMembersAgainstIndexer(objectTypeSymbol, objectTypeDecl, context); + this.checkTypeForDuplicateIndexSignatures(objectTypeSymbol); }; PullTypeResolver.prototype.resolveTypeAnnotation = function (typeAnnotation, context) { @@ -40749,11 +41829,11 @@ var TypeScript; var aliasType = null; var type = this.computeTypeReferenceSymbol(typeRef, context); - if (type.kind == 4 /* Container */) { + if (type.kind === 4 /* Container */) { var container = type; var instanceSymbol = container.getInstanceSymbol(); - if (instanceSymbol && (instanceSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind == 32768 /* ConstructorMethod */)) { + if (instanceSymbol && (instanceSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind === 32768 /* ConstructorMethod */)) { type = instanceSymbol.type.getAssociatedContainerType(); } } @@ -40770,7 +41850,7 @@ var TypeScript; } if (type && !type.isError()) { - if ((type.kind & 58728539 /* SomeType */) === 0) { + if ((type.kind & 58728795 /* SomeType */) === 0) { if (type.kind & 164 /* SomeContainer */) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeRef, TypeScript.DiagnosticCode.Type_reference_cannot_refer_to_container_0, [aliasType ? aliasType.toString() : type.toString()])); } else { @@ -40786,6 +41866,22 @@ var TypeScript; return type; }; + PullTypeResolver.prototype.getArrayType = function (elementType) { + var arraySymbol = elementType.getArrayType(); + + if (!arraySymbol) { + arraySymbol = this.createInstantiatedType(this.cachedArrayInterfaceType(), [elementType]); + + if (!arraySymbol) { + arraySymbol = this.semanticInfoChain.anyTypeSymbol; + } + + elementType.setArrayType(arraySymbol); + } + + return arraySymbol; + }; + PullTypeResolver.prototype.computeTypeReferenceSymbol = function (term, context) { switch (term.kind()) { case 60 /* AnyKeyword */: @@ -40820,7 +41916,7 @@ var TypeScript; var stringConstantAST = term; var enclosingDecl = this.getEnclosingDeclForAST(term); typeDeclSymbol = new TypeScript.PullStringConstantTypeSymbol(stringConstantAST.text()); - var decl = new TypeScript.PullSynthesizedDecl(stringConstantAST.text(), stringConstantAST.text(), typeDeclSymbol.kind, null, enclosingDecl, new TypeScript.TextSpan(stringConstantAST.start(), stringConstantAST.width()), enclosingDecl.semanticInfoChain()); + var decl = new TypeScript.PullSynthesizedDecl(stringConstantAST.text(), stringConstantAST.text(), typeDeclSymbol.kind, null, enclosingDecl, enclosingDecl.semanticInfoChain); typeDeclSymbol.addDeclaration(decl); } else if (term.kind() === 127 /* TypeQuery */) { var typeQuery = term; @@ -40839,24 +41935,14 @@ var TypeScript; } if (valueSymbol) { - typeDeclSymbol = valueSymbol.type; + typeDeclSymbol = valueSymbol.type.widenedType(this, typeQueryTerm, context); } else { typeDeclSymbol = this.getNewErrorTypeSymbol(); } } else if (term.kind() === 124 /* ArrayType */) { var arrayType = term; - var underlying = this.computeTypeReferenceSymbol(arrayType.type, context); - var arraySymbol = underlying.getArrayType(); - - if (!arraySymbol) { - arraySymbol = this.createInstantiatedType(this.cachedArrayInterfaceType(), [underlying]); - - if (!arraySymbol) { - arraySymbol = this.semanticInfoChain.anyTypeSymbol; - } - } - - typeDeclSymbol = arraySymbol; + var underlying = this.resolveTypeReference(arrayType.type, context); + typeDeclSymbol = this.getArrayType(underlying); } else { throw TypeScript.Errors.invalidOperation("unknown type"); } @@ -40879,19 +41965,27 @@ var TypeScript; }; PullTypeResolver.prototype.genericTypeIsUsedWithoutRequiredTypeArguments = function (typeSymbol, term, context) { - return typeSymbol.isNamedTypeSymbol() && typeSymbol.isGeneric() && !typeSymbol.isTypeParameter() && (typeSymbol.isResolved || typeSymbol.inResolution) && !typeSymbol.getIsSpecialized() && typeSymbol.getTypeParameters().length && typeSymbol.getTypeArguments() == null && this.isTypeRefWithoutTypeArgs(term); + if (!typeSymbol) { + return false; + } + + if (typeSymbol.isAlias()) { + return this.genericTypeIsUsedWithoutRequiredTypeArguments(typeSymbol.getExportAssignedTypeSymbol(), term, context); + } + + return typeSymbol.isNamedTypeSymbol() && typeSymbol.isGeneric() && !typeSymbol.isTypeParameter() && (typeSymbol.isResolved || typeSymbol.inResolution) && !typeSymbol.getIsSpecialized() && typeSymbol.getTypeParameters().length && typeSymbol.getTypeArguments() === null && this.isTypeRefWithoutTypeArgs(term); }; PullTypeResolver.prototype.resolveMemberVariableDeclaration = function (varDecl, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(varDecl, varDecl.modifiers, varDecl.variableDeclarator.propertyName, TypeScript.getType(varDecl.variableDeclarator), varDecl.variableDeclarator.equalsValueClause, context); + return this.resolveVariableDeclaratorOrParameterOrEnumElement(varDecl, varDecl.modifiers, varDecl.variableDeclarator.propertyName, TypeScript.ASTHelpers.getType(varDecl.variableDeclarator), varDecl.variableDeclarator.equalsValueClause, context); }; PullTypeResolver.prototype.resolvePropertySignature = function (varDecl, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.sentinelEmptyArray, varDecl.propertyName, TypeScript.getType(varDecl), null, context); + return this.resolveVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.sentinelEmptyArray, varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), null, context); }; PullTypeResolver.prototype.resolveVariableDeclarator = function (varDecl, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.getType(varDecl), varDecl.equalsValueClause, context); + return this.resolveVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), varDecl.equalsValueClause, context); }; PullTypeResolver.prototype.resolveParameterList = function (list, context) { @@ -40899,7 +41993,7 @@ var TypeScript; }; PullTypeResolver.prototype.resolveParameter = function (parameter, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.getType(parameter), parameter.equalsValueClause, context); + return this.resolveVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); }; PullTypeResolver.prototype.getEnumTypeSymbol = function (enumElement, context) { @@ -40932,7 +42026,7 @@ var TypeScript; var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - if (enclosingDecl && decl.kind == 2048 /* Parameter */) { + if (enclosingDecl && decl.kind === 2048 /* Parameter */) { enclosingDecl.ensureSymbolIsBound(); } @@ -40970,7 +42064,7 @@ var TypeScript; if (!(hasTypeExpr || init)) { var defaultType = this.semanticInfoChain.anyTypeSymbol; - if (declSymbol.isVarArg) { + if (declSymbol.isVarArg && this.cachedArrayInterfaceType()) { defaultType = this.createInstantiatedType(this.cachedArrayInterfaceType(), [defaultType]); } @@ -41012,7 +42106,7 @@ var TypeScript; } var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl ? wrapperDecl : enclosingDecl; + wrapperDecl = wrapperDecl || enclosingDecl; var typeExprSymbol = this.resolveTypeReference(typeExpr, context); @@ -41029,7 +42123,7 @@ var TypeScript; context.setTypeInContext(declParameterSymbol, typeExprSymbol); } } else { - if (typeExprSymbol == this.semanticInfoChain.anyTypeSymbol) { + if (typeExprSymbol === this.semanticInfoChain.anyTypeSymbol) { decl.setFlag(16777216 /* IsAnnotatedWithAny */); } @@ -41055,7 +42149,7 @@ var TypeScript; } } } - } else if (declSymbol.isVarArg && !(typeExprSymbol.isArrayNamedTypeReference() || typeExprSymbol == this.cachedArrayInterfaceType())) { + } else if (declSymbol.isVarArg && !(typeExprSymbol.isArrayNamedTypeReference() || typeExprSymbol === this.cachedArrayInterfaceType())) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); typeExprSymbol = this.getNewErrorTypeSymbol(); } @@ -41066,7 +42160,7 @@ var TypeScript; declParameterSymbol.type = typeExprSymbol; } - if (typeExprSymbol.kind == 16777216 /* FunctionType */ && !typeExprSymbol.getFunctionSymbol()) { + if (typeExprSymbol.kind === 16777216 /* FunctionType */ && !typeExprSymbol.getFunctionSymbol()) { typeExprSymbol.setFunctionSymbol(declSymbol); } } @@ -41081,7 +42175,7 @@ var TypeScript; var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; if (typeExprSymbol) { - context.pushContextualType(typeExprSymbol, context.inProvisionalResolution(), null); + context.pushNewContextualType(typeExprSymbol); } var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); @@ -41090,12 +42184,12 @@ var TypeScript; var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl ? wrapperDecl : enclosingDecl; + wrapperDecl = wrapperDecl || enclosingDecl; - var initExprSymbol = this.resolveAST(init, typeExprSymbol != null, context); + var initExprSymbol = this.resolveAST(init, typeExprSymbol !== null, context); if (typeExprSymbol) { - context.popContextualType(); + context.popAnyContextualType(); } if (!initExprSymbol) { @@ -41110,9 +42204,9 @@ var TypeScript; } } else { var initTypeSymbol = initExprSymbol.type; - var widenedInitTypeSymbol = this.widenType(initTypeSymbol, init.value, context); if (!hasTypeExpr) { + var widenedInitTypeSymbol = initTypeSymbol.widenedType(this, init.value, context); context.setTypeInContext(declSymbol, widenedInitTypeSymbol); if (declParameterSymbol) { @@ -41120,30 +42214,32 @@ var TypeScript; } if (this.compilationSettings.noImplicitAny()) { - if ((widenedInitTypeSymbol != initTypeSymbol) && (widenedInitTypeSymbol == this.semanticInfoChain.anyTypeSymbol)) { + if ((widenedInitTypeSymbol !== initTypeSymbol) && (widenedInitTypeSymbol === this.semanticInfoChain.anyTypeSymbol)) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); } } + + return widenedInitTypeSymbol; } } - return widenedInitTypeSymbol; + return initTypeSymbol; }; PullTypeResolver.prototype.typeCheckPropertySignature = function (varDecl, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.sentinelEmptyArray, varDecl.propertyName, TypeScript.getType(varDecl), null, context); + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.sentinelEmptyArray, varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), null, context); }; PullTypeResolver.prototype.typeCheckMemberVariableDeclaration = function (varDecl, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDecl, varDecl.modifiers, varDecl.variableDeclarator.propertyName, TypeScript.getType(varDecl), varDecl.variableDeclarator.equalsValueClause, context); + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDecl, varDecl.modifiers, varDecl.variableDeclarator.propertyName, TypeScript.ASTHelpers.getType(varDecl), varDecl.variableDeclarator.equalsValueClause, context); }; PullTypeResolver.prototype.typeCheckVariableDeclarator = function (varDecl, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.getType(varDecl), varDecl.equalsValueClause, context); + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), varDecl.equalsValueClause, context); }; PullTypeResolver.prototype.typeCheckParameter = function (parameter, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.getType(parameter), parameter.equalsValueClause, context); + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); }; PullTypeResolver.prototype.typeCheckVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { @@ -41199,7 +42295,7 @@ var TypeScript; } } else if (varDeclOrParameter.kind() !== 243 /* EnumElement */ && this.compilationSettings.noImplicitAny() && !this.isForInVariableDeclarator(varDeclOrParameter)) { var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl ? wrapperDecl : enclosingDecl; + wrapperDecl = wrapperDecl || enclosingDecl; if ((wrapperDecl.kind === 16384 /* Function */ || wrapperDecl.kind === 32768 /* ConstructorMethod */ || wrapperDecl.kind === 2097152 /* ConstructSignature */)) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [name.text(), enclosingDecl.name])); @@ -41211,7 +42307,7 @@ var TypeScript; } else if (TypeScript.hasFlag(parentDecl.flags, 8 /* Ambient */) && !TypeScript.hasFlag(wrapperDecl.flags, 2 /* Private */)) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [name.text(), enclosingDecl.name])); } - } else if (wrapperDecl.kind === 8388608 /* ObjectType */) { + } else if (decl.kind === 4096 /* Property */ && !declSymbol.getContainer().isNamedTypeSymbol()) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Member_0_of_object_type_implicitly_has_an_any_type, [name.text()])); } else if (wrapperDecl.kind !== 268435456 /* CatchBlock */) { if (!TypeScript.hasFlag(wrapperDecl.flags, 8 /* Ambient */)) { @@ -41225,16 +42321,16 @@ var TypeScript; if (init && varDeclOrParameter.kind() === 242 /* Parameter */) { var containerSignature = enclosingDecl.getSignatureSymbol(); if (containerSignature && !containerSignature.isDefinition()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Default_arguments_are_not_allowed_in_an_overload_parameter)); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Default_arguments_are_only_allowed_in_implementation)); } } - if (declSymbol.kind != 2048 /* Parameter */ && (declSymbol.kind != 4096 /* Property */ || declSymbol.getContainer().isNamedTypeSymbol())) { + if (declSymbol.kind !== 2048 /* Parameter */ && (declSymbol.kind !== 4096 /* Property */ || declSymbol.getContainer().isNamedTypeSymbol())) { this.checkSymbolPrivacy(declSymbol, declSymbol.type, function (symbol) { return _this.variablePrivacyErrorReporter(varDeclOrParameter, declSymbol, symbol, context); }); } - if ((declSymbol.kind != 4096 /* Property */ && declSymbol.kind != 67108864 /* EnumMember */) || declSymbol.anyDeclHasFlag(8388608 /* PropertyParameter */)) { + if ((declSymbol.kind !== 4096 /* Property */ && declSymbol.kind !== 67108864 /* EnumMember */) || declSymbol.anyDeclHasFlag(8388608 /* PropertyParameter */)) { this.checkNameForCompilerGeneratedDeclarationCollision(varDeclOrParameter, true, name, context); } }; @@ -41245,15 +42341,14 @@ var TypeScript; PullTypeResolver.prototype.checkSuperCaptureVariableCollides = function (superAST, isDeclaration, context) { var enclosingDecl = this.getEnclosingDeclForAST(superAST); - var declPath = enclosingDecl.getParentPath(); var classSymbol = this.getContextualClassSymbolForEnclosingDecl(superAST, enclosingDecl); if (classSymbol && !classSymbol.anyDeclHasFlag(8 /* Ambient */)) { - if (superAST.kind() == 242 /* Parameter */) { + if (superAST.kind() === 242 /* Parameter */) { var enclosingAST = this.getASTForDecl(enclosingDecl); if (enclosingAST.kind() !== 218 /* ParenthesizedArrowFunctionExpression */ && enclosingAST.kind() !== 219 /* SimpleArrowFunctionExpression */) { - var block = enclosingDecl.kind == 65536 /* Method */ ? enclosingAST.block : enclosingAST.block; + var block = enclosingDecl.kind === 65536 /* Method */ ? enclosingAST.block : enclosingAST.block; if (!block) { return; } @@ -41279,8 +42374,8 @@ var TypeScript; var enclosingDecl = this.getEnclosingDeclForAST(_thisAST); - var enclosingModule = TypeScript.getEnclosingModuleDeclaration(_thisAST); - if (TypeScript.isAnyNameOfModule(enclosingModule, _thisAST)) { + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(_thisAST); + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, _thisAST)) { enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); } @@ -41310,11 +42405,21 @@ var TypeScript; var typeParameterDecl = this.semanticInfoChain.getDeclForAST(typeParameterAST); var typeParameterSymbol = typeParameterDecl.getSymbol(); + this.resolveFirstTypeParameterDeclaration(typeParameterSymbol, context); + + if (typeParameterSymbol.isResolved && this.canTypeCheckAST(typeParameterAST, context)) { + this.typeCheckTypeParameterDeclaration(typeParameterAST, context); + } + + return typeParameterSymbol; + }; + + PullTypeResolver.prototype.resolveFirstTypeParameterDeclaration = function (typeParameterSymbol, context) { + var typeParameterDecl = typeParameterSymbol.getDeclarations()[0]; + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecl); + if (typeParameterSymbol.isResolved || typeParameterSymbol.inResolution) { - if (typeParameterSymbol.isResolved && this.canTypeCheckAST(typeParameterAST, context)) { - this.typeCheckTypeParameterDeclaration(typeParameterAST, context); - } - return typeParameterSymbol; + return; } typeParameterSymbol.startResolving(); @@ -41328,18 +42433,27 @@ var TypeScript; } typeParameterSymbol.setResolved(); - - if (this.canTypeCheckAST(typeParameterAST, context)) { - this.setTypeChecked(typeParameterAST, context); - } - - return typeParameterSymbol; }; PullTypeResolver.prototype.typeCheckTypeParameterDeclaration = function (typeParameterAST, context) { this.setTypeChecked(typeParameterAST, context); - this.resolveAST(typeParameterAST.constraint, false, context); + var constraint = this.resolveAST(typeParameterAST.constraint, false, context); + + if (constraint) { + var typeParametersAST = typeParameterAST.parent; + var typeParameters = []; + for (var i = 0; i < typeParametersAST.nonSeparatorCount(); i++) { + var currentTypeParameterAST = typeParametersAST.nonSeparatorAt(i); + var currentTypeParameterDecl = this.semanticInfoChain.getDeclForAST(currentTypeParameterAST); + var currentTypeParameter = this.semanticInfoChain.getSymbolForDecl(currentTypeParameterDecl); + typeParameters[currentTypeParameter.pullSymbolID] = currentTypeParameter; + } + + if (constraint.wrapsSomeTypeParameter(typeParameters)) { + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list); + } + } }; PullTypeResolver.prototype.resolveConstraint = function (constraint, context) { @@ -41364,6 +42478,7 @@ var TypeScript; case 219 /* SimpleArrowFunctionExpression */: case 218 /* ParenthesizedArrowFunctionExpression */: case 222 /* FunctionExpression */: + case 215 /* ObjectLiteralExpression */: go = false; break; @@ -41451,20 +42566,12 @@ var TypeScript; var returnType = bestCommonReturnType; var returnExpression = returnExpressions[returnExpressionSymbols.indexOf(returnType)]; - if (useContextualType && returnType == this.semanticInfoChain.anyTypeSymbol) { - var contextualType = context.getContextualType(); - - if (contextualType) { - returnType = contextualType; - } - } - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); var functionSymbol = functionDecl.getSymbol(); if (returnType) { var previousReturnType = returnType; - var newReturnType = this.widenType(returnType, returnExpression, context); + var newReturnType = returnType.widenedType(this, returnExpression, context); signature.returnType = newReturnType; if (!TypeScript.ArrayUtilities.contains(returnExpressionSymbols, bestCommonReturnType)) { @@ -41474,7 +42581,7 @@ var TypeScript; if (this.compilationSettings.noImplicitAny()) { if (previousReturnType !== newReturnType && newReturnType === this.semanticInfoChain.anyTypeSymbol) { var functionName = enclosingDecl.name; - if (functionName == "") { + if (functionName === "") { functionName = enclosingDecl.getFunctionExpressionName(); } @@ -41500,28 +42607,26 @@ var TypeScript; var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - if (funcDeclAST.parameterList) { - for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveAST(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), false, context); - } + for (var i = 0; i < funcDeclAST.callSignature.parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveAST(funcDeclAST.callSignature.parameterList.parameters.nonSeparatorAt(i), false, context); } this.resolveAST(funcDeclAST.block, false, context); if (funcDecl.getSignatureSymbol() && funcDecl.getSignatureSymbol().isDefinition() && this.enclosingClassIsDerived(funcDecl.getParentDecl())) { if (!this.constructorHasSuperCall(funcDeclAST)) { - context.postDiagnostic(new TypeScript.Diagnostic(funcDeclAST.fileName(), this.semanticInfoChain.lineMap(funcDeclAST.fileName()), funcDeclAST.start(), 11, TypeScript.DiagnosticCode.Constructors_for_derived_classes_must_contain_a_super_call)); + context.postDiagnostic(new TypeScript.Diagnostic(funcDeclAST.fileName(), this.semanticInfoChain.lineMap(funcDeclAST.fileName()), funcDeclAST.start(), "constructor".length, TypeScript.DiagnosticCode.Constructors_for_derived_classes_must_contain_a_super_call)); } else if (this.superCallMustBeFirstStatementInConstructor(funcDecl)) { var firstStatement = this.getFirstStatementOfBlockOrNull(funcDeclAST.block); if (!firstStatement || !this.isSuperInvocationExpressionStatement(firstStatement)) { - context.postDiagnostic(new TypeScript.Diagnostic(funcDeclAST.fileName(), this.semanticInfoChain.lineMap(funcDeclAST.fileName()), funcDeclAST.start(), 11, TypeScript.DiagnosticCode.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties)); + context.postDiagnostic(new TypeScript.Diagnostic(funcDeclAST.fileName(), this.semanticInfoChain.lineMap(funcDeclAST.fileName()), funcDeclAST.start(), "constructor".length, TypeScript.DiagnosticCode.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties)); } } } this.validateVariableDeclarationGroups(funcDecl, context); - this.checkFunctionTypePrivacy(funcDeclAST, false, null, TypeScript.Parameters.fromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); + this.checkFunctionTypePrivacy(funcDeclAST, false, null, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.callSignature.parameterList), null, funcDeclAST.block, context); this.typeCheckCallBacks.push(function (context) { _this.typeCheckFunctionOverloads(funcDeclAST, context); @@ -41533,9 +42638,18 @@ var TypeScript; if (constructorDecl.block) { var foundSuperCall = false; var pre = function (ast, walker) { - if (_this.isSuperInvocationExpression(ast)) { - foundSuperCall = true; - walker.options.stopWalking = true; + switch (ast.kind()) { + case 129 /* FunctionDeclaration */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + case 215 /* ObjectLiteralExpression */: + walker.options.goChildren = false; + default: + if (_this.isSuperInvocationExpression(ast)) { + foundSuperCall = true; + walker.options.stopWalking = true; + } } }; @@ -41546,19 +42660,31 @@ var TypeScript; return false; }; - PullTypeResolver.prototype.typeCheckFunctionExpression = function (funcDecl, context) { - this.typeCheckAnyFunctionExpression(funcDecl, funcDecl.callSignature.typeParameterList, TypeScript.getType(funcDecl), funcDecl.block, null, context); + PullTypeResolver.prototype.typeCheckFunctionExpression = function (funcDecl, isContextuallyTyped, context) { + this.typeCheckAnyFunctionExpression(funcDecl, funcDecl.callSignature.typeParameterList, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), funcDecl.callSignature.typeAnnotation, funcDecl.block, null, isContextuallyTyped, context); }; PullTypeResolver.prototype.typeCheckCallSignature = function (funcDecl, context) { - this.typeCheckFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.getType(funcDecl), null, context); + this.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); }; PullTypeResolver.prototype.typeCheckConstructSignature = function (funcDecl, context) { - this.typeCheckFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.getType(funcDecl), null, context); + this.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); }; - PullTypeResolver.prototype.typeCheckFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameters, returnTypeAnnotation, block, context) { + PullTypeResolver.prototype.typeCheckMethodSignature = function (funcDecl, context) { + this.typeCheckAnyFunctionDeclaration(funcDecl, false, funcDecl.propertyName, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); + }; + + PullTypeResolver.prototype.typeCheckMemberFunctionDeclaration = function (funcDecl, context) { + this.typeCheckAnyFunctionDeclaration(funcDecl, TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */), funcDecl.propertyName, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, context); + }; + + PullTypeResolver.prototype.containsSingleThrowStatement = function (block) { + return block !== null && block.statements.childCount() === 1 && block.statements.childAt(0).kind() === 157 /* ThrowStatement */; + }; + + PullTypeResolver.prototype.typeCheckAnyFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameters, returnTypeAnnotation, block, context) { var _this = this; this.setTypeChecked(funcDeclAST, context); @@ -41578,22 +42704,9 @@ var TypeScript; this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); this.validateVariableDeclarationGroups(funcDecl, context); - this.checkFunctionTypePrivacy(funcDeclAST, isStatic, typeParameters, TypeScript.Parameters.fromParameterList(parameters), returnTypeAnnotation, block, context); + this.checkFunctionTypePrivacy(funcDeclAST, isStatic, typeParameters, TypeScript.ASTHelpers.parametersFromParameterList(parameters), returnTypeAnnotation, block, context); - var signature = funcDecl.getSignatureSymbol(); - - var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; - - if (funcDeclAST.kind() !== 143 /* ConstructSignature */ && block && returnTypeAnnotation != null && !hasReturn) { - var isVoidOrAny = this.isAnyOrEquivalent(signature.returnType) || signature.returnType === this.semanticInfoChain.voidTypeSymbol; - - if (!isVoidOrAny && !(block.statements.childCount() > 0 && block.statements.childAt(0).kind() === 157 /* ThrowStatement */)) { - var funcName = funcDecl.getDisplayName(); - funcName = funcName ? funcName : "expression"; - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Function_0_declared_a_non_void_return_type_but_has_no_return_expression, [funcName])); - } - } + this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(funcDecl, returnTypeAnnotation, funcDecl.getSignatureSymbol().returnType, block, context); if (funcDecl.kind === 16384 /* Function */) { this.checkNameForCompilerGeneratedDeclarationCollision(funcDeclAST, true, name, context); @@ -41604,6 +42717,20 @@ var TypeScript; }); }; + PullTypeResolver.prototype.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement = function (functionDecl, returnTypeAnnotation, returnTypeSymbol, block, context) { + var hasReturn = TypeScript.hasFlag(functionDecl.flags, 4194304 /* HasReturnStatement */); + + if (block !== null && returnTypeAnnotation !== null && !hasReturn) { + var isVoidOrAny = this.isAnyOrEquivalent(returnTypeSymbol) || returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol; + + if (!isVoidOrAny && !this.containsSingleThrowStatement(block)) { + var funcName = functionDecl.getDisplayName() || TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Function_declared_a_non_void_return_type_but_has_no_return_expression)); + } + } + }; + PullTypeResolver.prototype.typeCheckIndexSignature = function (funcDeclAST, context) { var _this = this; this.setTypeChecked(funcDeclAST, context); @@ -41614,16 +42741,16 @@ var TypeScript; var enclosingDecl = this.getEnclosingDecl(funcDecl); - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.getType(funcDeclAST), context); + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); this.validateVariableDeclarationGroups(funcDecl, context); - this.checkFunctionTypePrivacy(funcDeclAST, false, null, TypeScript.Parameters.fromParameter(funcDeclAST.parameter), TypeScript.getType(funcDeclAST), null, context); + this.checkFunctionTypePrivacy(funcDeclAST, false, null, TypeScript.ASTHelpers.parametersFromParameter(funcDeclAST.parameter), TypeScript.ASTHelpers.getType(funcDeclAST), null, context); var signature = funcDecl.getSignatureSymbol(); this.typeCheckCallBacks.push(function (context) { var parentSymbol = funcDecl.getSignatureSymbol().getContainer(); - var allIndexSignatures = _this.getBothKindsOfIndexSignatures(parentSymbol, context); + var allIndexSignatures = _this.getBothKindsOfIndexSignaturesExcludingAugmentedType(parentSymbol, context); var stringIndexSignature = allIndexSignatures.stringSignature; var numberIndexSignature = allIndexSignatures.numericSignature; var isNumericIndexer = numberIndexSignature === signature; @@ -41631,12 +42758,12 @@ var TypeScript; if (numberIndexSignature && stringIndexSignature && (isNumericIndexer || stringIndexSignature.getDeclarations()[0].getParentDecl() !== numberIndexSignature.getDeclarations()[0].getParentDecl())) { var comparisonInfo = new TypeComparisonInfo(); - if (!_this.sourceIsSubtypeOfTarget(numberIndexSignature.returnType, stringIndexSignature.returnType, funcDeclAST, context, comparisonInfo)) { + if (!_this.sourceIsAssignableToTarget(numberIndexSignature.returnType, stringIndexSignature.returnType, funcDeclAST, context, comparisonInfo)) { var enclosingSymbol = _this.getEnclosingSymbolForAST(funcDeclAST); if (comparisonInfo.message) { - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Numeric_indexer_type_0_must_be_a_subtype_of_string_indexer_type_1_NL_2, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol), comparisonInfo.message])); + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Numeric_indexer_type_0_must_be_assignable_to_string_indexer_type_1_NL_2, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol), comparisonInfo.message])); } else { - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Numeric_indexer_type_0_must_be_a_subtype_of_string_indexer_type_1, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol)])); + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Numeric_indexer_type_0_must_be_assignable_to_string_indexer_type_1, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol)])); } } } @@ -41657,7 +42784,7 @@ var TypeScript; if (indexerKindMatchesMemberNameKind || onlyStringIndexerIsPresent) { var comparisonInfo = new TypeComparisonInfo(); - if (!_this.sourceIsSubtypeOfTarget(allMembers[i].type, signature.returnType, funcDeclAST, context, comparisonInfo, false)) { + if (!_this.sourceIsAssignableToTarget(allMembers[i].type, signature.returnType, funcDeclAST, context, comparisonInfo, false)) { _this.reportErrorThatMemberIsNotSubtypeOfIndexer(allMembers[i], signature, funcDeclAST, context, comparisonInfo); } } @@ -41693,35 +42820,35 @@ var TypeScript; }; PullTypeResolver.prototype.resolveMemberFunctionDeclaration = function (funcDecl, context) { - return this.resolveFunctionDeclaration(funcDecl, TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */), funcDecl.propertyName, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.getType(funcDecl), funcDecl.block, context); + return this.resolveFunctionDeclaration(funcDecl, TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */), funcDecl.propertyName, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, context); }; PullTypeResolver.prototype.resolveCallSignature = function (funcDecl, context) { - return this.resolveFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.getType(funcDecl), null, context); + return this.resolveFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); }; PullTypeResolver.prototype.resolveConstructSignature = function (funcDecl, context) { - return this.resolveFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.getType(funcDecl), null, context); + return this.resolveFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); }; PullTypeResolver.prototype.resolveMethodSignature = function (funcDecl, context) { - return this.resolveFunctionDeclaration(funcDecl, false, funcDecl.propertyName, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.getType(funcDecl), null, context); + return this.resolveFunctionDeclaration(funcDecl, false, funcDecl.propertyName, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); }; PullTypeResolver.prototype.resolveAnyFunctionDeclaration = function (funcDecl, context) { - return this.resolveFunctionDeclaration(funcDecl, TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */), funcDecl.identifier, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.getType(funcDecl), funcDecl.block, context); + return this.resolveFunctionDeclaration(funcDecl, TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */), funcDecl.identifier, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, context); }; PullTypeResolver.prototype.resolveFunctionExpression = function (funcDecl, isContextuallyTyped, context) { - return this.resolveAnyFunctionExpression(funcDecl, funcDecl.callSignature.typeParameterList, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList), TypeScript.getType(funcDecl), funcDecl.block, null, isContextuallyTyped, context); + return this.resolveAnyFunctionExpression(funcDecl, funcDecl.callSignature.typeParameterList, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, null, isContextuallyTyped, context); }; PullTypeResolver.prototype.resolveSimpleArrowFunctionExpression = function (funcDecl, isContextuallyTyped, context) { - return this.resolveAnyFunctionExpression(funcDecl, null, TypeScript.Parameters.fromIdentifier(funcDecl.identifier), null, funcDecl.block, funcDecl.expression, isContextuallyTyped, context); + return this.resolveAnyFunctionExpression(funcDecl, null, TypeScript.ASTHelpers.parametersFromIdentifier(funcDecl.identifier), null, funcDecl.block, funcDecl.expression, isContextuallyTyped, context); }; PullTypeResolver.prototype.resolveParenthesizedArrowFunctionExpression = function (funcDecl, isContextuallyTyped, context) { - return this.resolveAnyFunctionExpression(funcDecl, funcDecl.callSignature.typeParameterList, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList), TypeScript.getType(funcDecl), funcDecl.block, funcDecl.expression, isContextuallyTyped, context); + return this.resolveAnyFunctionExpression(funcDecl, funcDecl.callSignature.typeParameterList, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, funcDecl.expression, isContextuallyTyped, context); }; PullTypeResolver.prototype.getEnclosingClassDeclaration = function (ast) { @@ -41786,18 +42913,16 @@ var TypeScript; } signature.startResolving(); - if (funcDeclAST.parameterList) { - var prevInTypeCheck = context.inTypeCheck; + var prevInTypeCheck = context.inTypeCheck; - context.inTypeCheck = false; + context.inTypeCheck = false; - for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), context); - } - - context.inTypeCheck = prevInTypeCheck; + for (var i = 0; i < funcDeclAST.callSignature.parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(funcDeclAST.callSignature.parameterList.parameters.nonSeparatorAt(i), context); } + context.inTypeCheck = prevInTypeCheck; + if (signature.isGeneric()) { if (funcSymbol) { funcSymbol.type.setHasGenericSignature(); @@ -41855,9 +42980,9 @@ var TypeScript; if (signature.inResolution) { if (funcDeclAST.typeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(TypeScript.getType(funcDeclAST), context); + var returnTypeSymbol = this.resolveTypeReference(TypeScript.ASTHelpers.getType(funcDeclAST), context); if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(TypeScript.getType(funcDeclAST), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(TypeScript.ASTHelpers.getType(funcDeclAST), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); signature.returnType = this.getNewErrorTypeSymbol(); hadError = true; } else { @@ -41891,7 +43016,7 @@ var TypeScript; } if (funcDeclAST.typeAnnotation) { - returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.getType(funcDeclAST), context); + returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); if (!returnTypeSymbol) { signature.returnType = this.getNewErrorTypeSymbol(); @@ -41901,16 +43026,6 @@ var TypeScript; } } else { signature.returnType = this.semanticInfoChain.anyTypeSymbol; - var parentDeclFlags = 0 /* None */; - if (TypeScript.hasFlag(funcDecl.kind, 65536 /* Method */) || TypeScript.hasFlag(funcDecl.kind, 32768 /* ConstructorMethod */)) { - var parentDecl = funcDecl.getParentDecl(); - parentDeclFlags = parentDecl.flags; - } - - if (this.compilationSettings.noImplicitAny() && (!TypeScript.hasFlag(parentDeclFlags, 8 /* Ambient */) || (TypeScript.hasFlag(parentDeclFlags, 8 /* Ambient */) && !TypeScript.hasFlag(funcDecl.flags, 2 /* Private */)))) { - var funcDeclASTName = name; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, ["Indexer"])); - } } if (!hadError) { @@ -41949,7 +43064,7 @@ var TypeScript; if (signature) { if (signature.isResolved) { if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); + this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); } return funcSymbol; } @@ -42073,7 +43188,7 @@ var TypeScript; } if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); + this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); } return funcSymbol; @@ -42081,7 +43196,7 @@ var TypeScript; PullTypeResolver.prototype.resolveGetterReturnTypeAnnotation = function (getterFunctionDeclarationAst, enclosingDecl, context) { if (getterFunctionDeclarationAst && getterFunctionDeclarationAst.typeAnnotation) { - return this.resolveTypeReference(TypeScript.getType(getterFunctionDeclarationAst), context); + return this.resolveTypeReference(TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), context); } return null; @@ -42090,7 +43205,7 @@ var TypeScript; PullTypeResolver.prototype.resolveSetterArgumentTypeAnnotation = function (setterFunctionDeclarationAst, enclosingDecl, context) { if (setterFunctionDeclarationAst && setterFunctionDeclarationAst.parameterList && setterFunctionDeclarationAst.parameterList.parameters.nonSeparatorCount() > 0) { var parameter = setterFunctionDeclarationAst.parameterList.parameters.nonSeparatorAt(0); - return this.resolveTypeReference(TypeScript.getType(parameter), context); + return this.resolveTypeReference(TypeScript.ASTHelpers.getType(parameter), context); } return null; @@ -42129,7 +43244,7 @@ var TypeScript; accessorSymbol.startResolving(); if (hasGetter) { - getterSymbol = this.resolveGetAccessorDeclaration(getterFunctionDeclarationAst, getterFunctionDeclarationAst.parameterList, TypeScript.getType(getterFunctionDeclarationAst), getterFunctionDeclarationAst.block, setterAnnotatedType, context); + getterSymbol = this.resolveGetAccessorDeclaration(getterFunctionDeclarationAst, getterFunctionDeclarationAst.parameterList, TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), getterFunctionDeclarationAst.block, setterAnnotatedType, context); } if (hasSetter) { @@ -42156,7 +43271,7 @@ var TypeScript; } } - if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol)) { + if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { accessorSymbol.type = this.getNewErrorTypeSymbol(); } else { accessorSymbol.type = getterSuppliedTypeSymbol; @@ -42189,12 +43304,12 @@ var TypeScript; var getterSymbol = accessorSymbol.getGetter(); var setterSymbol = accessorSymbol.getSetter(); - var isGetter = funcDeclAst.kind() == 139 /* GetAccessor */; + var isGetter = funcDeclAst.kind() === 139 /* GetAccessor */; if (isGetter) { var getterFunctionDeclarationAst = funcDeclAst; - context.pushContextualType(getterSymbol.type, context.inProvisionalResolution(), null); + context.pushNewContextualType(getterSymbol.type); this.typeCheckGetAccessorDeclaration(getterFunctionDeclarationAst, context); - context.popContextualType(); + context.popAnyContextualType(); } else { var setterFunctionDeclarationAst = funcDeclAst; this.typeCheckSetAccessorDeclaration(setterFunctionDeclarationAst, context); @@ -42272,7 +43387,7 @@ var TypeScript; var setterSuppliedTypeSymbol = setterParameters[0].type; var getterSuppliedTypeSymbol = getterSig.returnType; - if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol)) { + if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type)); } } @@ -42283,7 +43398,7 @@ var TypeScript; var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); var accessorSymbol = funcDecl.getSymbol(); - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.getType(funcDeclAST), context); + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); this.resolveAST(funcDeclAST.block, false, context); @@ -42291,10 +43406,10 @@ var TypeScript; var enclosingDecl = this.getEnclosingDecl(funcDecl); - var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; var funcNameAST = funcDeclAST.propertyName; - if (!hasReturn && !(funcDeclAST.block.statements.childCount() > 0 && funcDeclAST.block.statements.childAt(0).kind() === 157 /* ThrowStatement */)) { + if (!hasReturn && !this.containsSingleThrowStatement(funcDeclAST.block)) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getters_must_return_a_value)); } @@ -42304,18 +43419,18 @@ var TypeScript; var setterIsPrivate = TypeScript.hasFlag(setterDecl.flags, 2 /* Private */); var getterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); - if (getterIsPrivate != setterIsPrivate) { + if (getterIsPrivate !== setterIsPrivate) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility)); } this.checkIfGetterAndSetterTypeMatch(funcDeclAST, context); } - this.checkFunctionTypePrivacy(funcDeclAST, TypeScript.hasModifier(funcDeclAST.modifiers, 16 /* Static */), null, TypeScript.Parameters.fromParameterList(funcDeclAST.parameterList), TypeScript.getType(funcDeclAST), funcDeclAST.block, context); + this.checkFunctionTypePrivacy(funcDeclAST, TypeScript.hasModifier(funcDeclAST.modifiers, 16 /* Static */), null, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), TypeScript.ASTHelpers.getType(funcDeclAST), funcDeclAST.block, context); }; PullTypeResolver.hasSetAccessorParameterTypeAnnotation = function (setAccessor) { - return setAccessor.parameterList && setAccessor.parameterList.parameters.nonSeparatorCount() > 0 && setAccessor.parameterList.parameters.nonSeparatorAt(0).typeAnnotation != null; + return setAccessor.parameterList && setAccessor.parameterList.parameters.nonSeparatorCount() > 0 && setAccessor.parameterList.parameters.nonSeparatorAt(0).typeAnnotation !== null; }; PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, parameterList, context) { @@ -42350,10 +43465,6 @@ var TypeScript; signature.returnType = this.semanticInfoChain.voidTypeSymbol; - if (signature.hasAGenericParameter) { - setterTypeSymbol.setHasGenericSignature(); - } - if (!hadError) { signature.setResolved(); } @@ -42376,7 +43487,7 @@ var TypeScript; this.validateVariableDeclarationGroups(funcDecl, context); - var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; var getter = accessorSymbol.getGetter(); @@ -42387,7 +43498,7 @@ var TypeScript; var getterIsPrivate = TypeScript.hasFlag(getterDecl.flags, 2 /* Private */); var setterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); - if (getterIsPrivate != setterIsPrivate) { + if (getterIsPrivate !== setterIsPrivate) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility)); } @@ -42395,13 +43506,13 @@ var TypeScript; } else { if (this.compilationSettings.noImplicitAny()) { var setterFunctionDeclarationAst = funcDeclAST; - if (!PullTypeResolver.hasSetAccessorParameterTypeAnnotation(setterFunctionDeclarationAst) && accessorSymbol.type == this.semanticInfoChain.anyTypeSymbol) { + if (!PullTypeResolver.hasSetAccessorParameterTypeAnnotation(setterFunctionDeclarationAst) && accessorSymbol.type === this.semanticInfoChain.anyTypeSymbol) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_get_accessor_and_parameter_type_annotation_on_set_accessor_implicitly_has_an_any_type, [setterFunctionDeclarationAst.propertyName.text()])); } } } - this.checkFunctionTypePrivacy(funcDeclAST, TypeScript.hasModifier(funcDeclAST.modifiers, 16 /* Static */), null, TypeScript.Parameters.fromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); + this.checkFunctionTypePrivacy(funcDeclAST, TypeScript.hasModifier(funcDeclAST.modifiers, 16 /* Static */), null, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); }; PullTypeResolver.prototype.resolveList = function (list, context) { @@ -42497,7 +43608,7 @@ var TypeScript; var nodeType = unaryExpression.kind(); var expression = this.resolveAST(unaryExpression.operand, false, context); - if (nodeType == 164 /* PlusExpression */ || nodeType == 165 /* NegateExpression */ || nodeType == 166 /* BitwiseNotExpression */) { + if (nodeType === 164 /* PlusExpression */ || nodeType == 165 /* NegateExpression */ || nodeType == 166 /* BitwiseNotExpression */) { return; } @@ -42632,14 +43743,14 @@ var TypeScript; var enclosingSymbol = this.getEnclosingSymbolForAST(binaryExpression); var isValidLHS = this.isAnyOrEquivalent(lhsType) || lhsType.isObject() || lhsType.isTypeParameter(); - var isValidRHS = this.isAnyOrEquivalent(rhsType) || this.typeIsSubtypeOfFunction(rhsType, binaryExpression, context); + var isValidRHS = this.isAnyOrEquivalent(rhsType) || this.typeIsAssignableToFunction(rhsType, binaryExpression, context); if (!isValidLHS) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter)); } if (!isValidRHS) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_a_subtype_of_the_Function_interface_type)); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type)); } }; @@ -42650,8 +43761,6 @@ var TypeScript; this.resolveAST(commaExpression.left, false, context); } - var rhsType = this.resolveAST(commaExpression.right, false, context).type; - return this.resolveAST(commaExpression.right, false, context).type; }; @@ -42678,7 +43787,7 @@ var TypeScript; } if (!isValidRHS) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter)); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter)); } }; @@ -42707,29 +43816,27 @@ var TypeScript; PullTypeResolver.prototype.typeCheckForInStatement = function (forInStatement, context) { this.setTypeChecked(forInStatement, context); - var rhsType = this.resolveAST(forInStatement.expression, false, context).type; - var lval = forInStatement.variableDeclaration || forInStatement.left; - - var varSym = this.resolveAST(lval, false, context); - if (forInStatement.variableDeclaration) { var declaration = forInStatement.variableDeclaration; - var varDecl = declaration.declarators.nonSeparatorAt(0); - if (varDecl.typeAnnotation) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(lval, TypeScript.DiagnosticCode.Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation)); + if (declaration.declarators.nonSeparatorCount() === 1) { + var varDecl = declaration.declarators.nonSeparatorAt(0); + + if (varDecl.typeAnnotation) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declaration, TypeScript.DiagnosticCode.Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation)); + } } + } else { + var varSym = this.resolveAST(forInStatement.left, false, context); + var isStringOrNumber = varSym.type === this.semanticInfoChain.stringTypeSymbol || this.isAnyOrEquivalent(varSym.type); - var varSym = this.getSymbolForAST(varDecl, context); + if (!isStringOrNumber) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(forInStatement.left, TypeScript.DiagnosticCode.Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any)); + } } - var isStringOrNumber = varSym.type === this.semanticInfoChain.stringTypeSymbol || this.isAnyOrEquivalent(varSym.type); - - var isValidRHS = rhsType && (this.isAnyOrEquivalent(rhsType) || !rhsType.isPrimitive()); - - if (!isStringOrNumber) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(lval, TypeScript.DiagnosticCode.Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any)); - } + var rhsType = this.resolveAST(forInStatement.expression, false, context).type; + var isValidRHS = rhsType && (this.isAnyOrEquivalent(rhsType) || rhsType.isObject() || rhsType.isTypeParameter()); if (!isValidRHS) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(forInStatement.expression, TypeScript.DiagnosticCode.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter)); @@ -42908,23 +44015,23 @@ var TypeScript; if (enclosingFunction) { var enclosingDeclAST = this.getASTForDecl(enclosingFunction); - var typeAnnotation = TypeScript.getType(enclosingDeclAST); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); if (typeAnnotation) { var returnTypeAnnotationSymbol = this.resolveTypeReference(typeAnnotation, context); if (returnTypeAnnotationSymbol) { isContextuallyTyped = true; - context.pushContextualType(returnTypeAnnotationSymbol, context.inProvisionalResolution(), null); + context.pushNewContextualType(returnTypeAnnotationSymbol); } } else { var currentContextualType = context.getContextualType(); if (currentContextualType && currentContextualType.isFunction()) { - var currentContextTypeDecls = currentContextualType.getDeclarations(); - var currentContextualTypeSignatureSymbol = currentContextTypeDecls && currentContextTypeDecls.length > 0 ? currentContextTypeDecls[0].getSignatureSymbol() : currentContextualType.getCallSignatures()[0]; + var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); + var currentContextualTypeSignatureSymbol = contextualSignatures[0]; var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; if (currentContextualTypeReturnTypeSymbol) { isContextuallyTyped = true; - context.pushContextualType(currentContextualTypeReturnTypeSymbol, context.inProvisionalResolution(), null); + context.propagateContextualType(currentContextualTypeReturnTypeSymbol); } } } @@ -42932,7 +44039,7 @@ var TypeScript; var result = this.resolveAST(expression, isContextuallyTyped, context).type; if (isContextuallyTyped) { - context.popContextualType(); + context.popAnyContextualType(); } return result; @@ -42959,7 +44066,7 @@ var TypeScript; if (enclosingFunction) { var enclosingDeclAST = this.getASTForDecl(enclosingFunction); - var typeAnnotation = TypeScript.getType(enclosingDeclAST); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); if (typeAnnotation || enclosingFunction.kind === 262144 /* GetAccessor */) { var signatureSymbol = enclosingFunction.getSignatureSymbol(); var sigReturnType = signatureSymbol.returnType; @@ -42968,22 +44075,6 @@ var TypeScript; var comparisonInfo = new TypeComparisonInfo(); var upperBound = null; - if (expressionType.isTypeParameter()) { - upperBound = expressionType.getConstraint(); - - if (upperBound) { - expressionType = upperBound; - } - } - - if (sigReturnType.isTypeParameter()) { - upperBound = sigReturnType.getConstraint(); - - if (upperBound) { - sigReturnType = upperBound; - } - } - this.resolveDeclaredSymbol(expressionType, context); this.resolveDeclaredSymbol(sigReturnType, context); @@ -43081,8 +44172,11 @@ var TypeScript; var breakableLabels = this.getEnclosingLabels(ast, true, false); - if (TypeScript.ArrayUtilities.contains(breakableLabels, labelIdentifier)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast.identifier, TypeScript.DiagnosticCode.Duplicate_identifier_0, [labelIdentifier])); + var matchingLabel = TypeScript.ArrayUtilities.firstOrDefault(breakableLabels, function (s) { + return s.identifier.valueText() === labelIdentifier; + }); + if (matchingLabel) { + context.postDiagnostic(this.semanticInfoChain.duplicateIdentifierDiagnosticFromAST(ast.identifier, labelIdentifier, matchingLabel)); } this.resolveAST(ast.statement, false, context); @@ -43157,13 +44251,13 @@ var TypeScript; return false; }; - PullTypeResolver.prototype.inIterationStatement = function (ast) { + PullTypeResolver.prototype.inIterationStatement = function (ast, crossFunctions) { while (ast) { if (this.isIterationStatement(ast)) { return true; } - if (this.isAnyFunctionExpressionOrDeclaration(ast)) { + if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { return false; } @@ -43181,10 +44275,10 @@ var TypeScript; if (ast.kind() === 160 /* LabeledStatement */) { var labeledStatement = ast; if (breakable) { - result.push(labeledStatement.identifier.valueText()); + result.push(labeledStatement); } else { if (this.labelIsOnContinuableConstruct(labeledStatement.statement)) { - result.push(labeledStatement.identifier.valueText()); + result.push(labeledStatement); } } } @@ -43202,15 +44296,23 @@ var TypeScript; PullTypeResolver.prototype.typeCheckContinueStatement = function (ast, context) { this.setTypeChecked(ast, context); - if (!this.inIterationStatement(ast)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.continue_statement_can_only_be_used_within_an_enclosing_iteration_statement)); + if (!this.inIterationStatement(ast, false)) { + if (this.inIterationStatement(ast, true)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Jump_target_cannot_cross_function_boundary)); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.continue_statement_can_only_be_used_within_an_enclosing_iteration_statement)); + } } else if (ast.identifier) { var continuableLabels = this.getEnclosingLabels(ast, false, false); - if (!TypeScript.ArrayUtilities.contains(continuableLabels, ast.identifier.valueText())) { + if (!TypeScript.ArrayUtilities.any(continuableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { var continuableLabels = this.getEnclosingLabels(ast, false, true); - if (TypeScript.ArrayUtilities.contains(continuableLabels, ast.identifier.valueText())) { + if (TypeScript.ArrayUtilities.any(continuableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Jump_target_cannot_cross_function_boundary)); } else { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Jump_target_not_found)); @@ -43233,16 +44335,24 @@ var TypeScript; if (ast.identifier) { var breakableLabels = this.getEnclosingLabels(ast, true, false); - if (!TypeScript.ArrayUtilities.contains(breakableLabels, ast.identifier.valueText())) { + if (!TypeScript.ArrayUtilities.any(breakableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { var breakableLabels = this.getEnclosingLabels(ast, true, true); - if (TypeScript.ArrayUtilities.contains(breakableLabels, ast.identifier.valueText())) { + if (TypeScript.ArrayUtilities.any(breakableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Jump_target_cannot_cross_function_boundary)); } else { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Jump_target_not_found)); } } - } else if (!this.inIterationStatement(ast) && !this.inSwitchStatement(ast)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement)); + } else if (!this.inIterationStatement(ast, false) && !this.inSwitchStatement(ast)) { + if (this.inIterationStatement(ast, true)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Jump_target_cannot_cross_function_boundary)); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement)); + } } }; @@ -43257,6 +44367,10 @@ var TypeScript; return symbol; } + if (ast.isExpression() && !isTypesOnlyLocation(ast)) { + return this.resolveExpressionAST(ast, isContextuallyTyped, context); + } + var nodeType = ast.kind(); switch (nodeType) { @@ -43322,9 +44436,6 @@ var TypeScript; case 133 /* ImportDeclaration */: return this.resolveImportDeclaration(ast, context); - case 215 /* ObjectLiteralExpression */: - return this.resolveObjectLiteralExpression(ast, isContextuallyTyped, context); - case 240 /* SimplePropertyAssignment */: return this.resolveSimplePropertyAssignment(ast, isContextuallyTyped, context); @@ -43332,14 +44443,8 @@ var TypeScript; return this.resolveFunctionPropertyAssignment(ast, isContextuallyTyped, context); case 11 /* IdentifierName */: - if (isTypesOnlyLocation(ast)) { - return this.resolveTypeNameExpression(ast, context); - } else { - return this.resolveNameExpression(ast, context); - } - - case 212 /* MemberAccessExpression */: - return this.resolveMemberAccessExpression(ast, context); + TypeScript.Debug.assert(isTypesOnlyLocation(ast)); + return this.resolveTypeNameExpression(ast, context); case 121 /* QualifiedName */: return this.resolveQualifiedName(ast, context); @@ -43372,6 +44477,94 @@ var TypeScript; case 129 /* FunctionDeclaration */: return this.resolveAnyFunctionDeclaration(ast, context); + case 244 /* TypeAnnotation */: + return this.resolveTypeAnnotation(ast, context); + + case 134 /* ExportAssignment */: + return this.resolveExportAssignmentStatement(ast, context); + + case 157 /* ThrowStatement */: + return this.resolveThrowStatement(ast, context); + + case 149 /* ExpressionStatement */: + return this.resolveExpressionStatement(ast, context); + + case 154 /* ForStatement */: + return this.resolveForStatement(ast, context); + + case 155 /* ForInStatement */: + return this.resolveForInStatement(ast, context); + + case 158 /* WhileStatement */: + return this.resolveWhileStatement(ast, context); + + case 161 /* DoStatement */: + return this.resolveDoStatement(ast, context); + + case 147 /* IfStatement */: + return this.resolveIfStatement(ast, context); + + case 235 /* ElseClause */: + return this.resolveElseClause(ast, context); + + case 146 /* Block */: + return this.resolveBlock(ast, context); + + case 148 /* VariableStatement */: + return this.resolveVariableStatement(ast, context); + + case 163 /* WithStatement */: + return this.resolveWithStatement(ast, context); + + case 159 /* TryStatement */: + return this.resolveTryStatement(ast, context); + + case 236 /* CatchClause */: + return this.resolveCatchClause(ast, context); + + case 237 /* FinallyClause */: + return this.resolveFinallyClause(ast, context); + + case 150 /* ReturnStatement */: + return this.resolveReturnStatement(ast, context); + + case 151 /* SwitchStatement */: + return this.resolveSwitchStatement(ast, context); + + case 153 /* ContinueStatement */: + return this.resolveContinueStatement(ast, context); + + case 152 /* BreakStatement */: + return this.resolveBreakStatement(ast, context); + + case 160 /* LabeledStatement */: + return this.resolveLabeledStatement(ast, context); + } + + return this.semanticInfoChain.anyTypeSymbol; + }; + + PullTypeResolver.prototype.resolveExpressionAST = function (ast, isContextuallyOrInferentiallyTyped, context) { + var expressionSymbol = this.resolveExpressionWorker(ast, isContextuallyOrInferentiallyTyped, context); + + if (isContextuallyOrInferentiallyTyped && context.isInferentiallyTyping()) { + return this.alterPotentialGenericFunctionTypeToInstantiatedFunctionTypeForTypeArgumentInference(expressionSymbol, context); + } else { + return expressionSymbol; + } + }; + + PullTypeResolver.prototype.resolveExpressionWorker = function (ast, isContextuallyTyped, context) { + switch (ast.kind()) { + case 215 /* ObjectLiteralExpression */: + return this.resolveObjectLiteralExpression(ast, isContextuallyTyped, context); + + case 11 /* IdentifierName */: + return this.resolveNameExpression(ast, context); + + case 212 /* MemberAccessExpression */: + return this.resolveMemberAccessExpression(ast, context); + case 222 /* FunctionExpression */: return this.resolveFunctionExpression(ast, isContextuallyTyped, context); @@ -43399,12 +44592,6 @@ var TypeScript; case 220 /* CastExpression */: return this.resolveCastExpression(ast, context); - case 244 /* TypeAnnotation */: - return this.resolveTypeAnnotation(ast, context); - - case 134 /* ExportAssignment */: - return this.resolveExportAssignmentStatement(ast, context); - case 13 /* NumericLiteral */: return this.semanticInfoChain.numberTypeSymbol; @@ -43486,9 +44673,6 @@ var TypeScript; case 171 /* TypeOfExpression */: return this.resolveTypeOfExpression(ast, context); - case 157 /* ThrowStatement */: - return this.resolveThrowStatement(ast, context); - case 170 /* DeleteExpression */: return this.resolveDeleteExpression(ast, context); @@ -43501,9 +44685,6 @@ var TypeScript; case 217 /* ParenthesizedExpression */: return this.resolveParenthesizedExpression(ast, context); - case 149 /* ExpressionStatement */: - return this.resolveExpressionStatement(ast, context); - case 200 /* InstanceOfExpression */: return this.resolveInstanceOfExpression(ast, context); @@ -43513,59 +44694,11 @@ var TypeScript; case 201 /* InExpression */: return this.resolveInExpression(ast, context); - case 154 /* ForStatement */: - return this.resolveForStatement(ast, context); - - case 155 /* ForInStatement */: - return this.resolveForInStatement(ast, context); - - case 158 /* WhileStatement */: - return this.resolveWhileStatement(ast, context); - - case 161 /* DoStatement */: - return this.resolveDoStatement(ast, context); - - case 147 /* IfStatement */: - return this.resolveIfStatement(ast, context); - - case 235 /* ElseClause */: - return this.resolveElseClause(ast, context); - - case 146 /* Block */: - return this.resolveBlock(ast, context); - - case 148 /* VariableStatement */: - return this.resolveVariableStatement(ast, context); - - case 163 /* WithStatement */: - return this.resolveWithStatement(ast, context); - - case 159 /* TryStatement */: - return this.resolveTryStatement(ast, context); - - case 236 /* CatchClause */: - return this.resolveCatchClause(ast, context); - - case 237 /* FinallyClause */: - return this.resolveFinallyClause(ast, context); - - case 150 /* ReturnStatement */: - return this.resolveReturnStatement(ast, context); - - case 151 /* SwitchStatement */: - return this.resolveSwitchStatement(ast, context); - - case 153 /* ContinueStatement */: - return this.resolveContinueStatement(ast, context); - - case 152 /* BreakStatement */: - return this.resolveBreakStatement(ast, context); - - case 160 /* LabeledStatement */: - return this.resolveLabeledStatement(ast, context); + case 223 /* OmittedExpression */: + return this.semanticInfoChain.undefinedTypeSymbol; } - return this.semanticInfoChain.anyTypeSymbol; + TypeScript.Debug.fail("resolveExpressionASTWorker: Missing expression kind: " + TypeScript.SyntaxKind[ast.kind()]); }; PullTypeResolver.prototype.typeCheckAST = function (ast, isContextuallyTyped, context) { @@ -43644,8 +44777,25 @@ var TypeScript; return; case 222 /* FunctionExpression */: - this.typeCheckFunctionExpression(ast, context); - break; + this.typeCheckFunctionExpression(ast, isContextuallyTyped, context); + return; + + case 137 /* ConstructorDeclaration */: + this.typeCheckConstructorDeclaration(ast, context); + return; + + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + this.typeCheckAccessorDeclaration(ast, context); + return; + + case 135 /* MemberFunctionDeclaration */: + this.typeCheckMemberFunctionDeclaration(ast, context); + return; + + case 145 /* MethodSignature */: + this.typeCheckMethodSignature(ast, context); + return; case 144 /* IndexSignature */: this.typeCheckIndexSignature(ast, context); @@ -43653,24 +44803,24 @@ var TypeScript; case 142 /* CallSignature */: this.typeCheckCallSignature(ast, context); - break; + return; case 143 /* ConstructSignature */: this.typeCheckConstructSignature(ast, context); - break; + return; case 129 /* FunctionDeclaration */: { var funcDecl = ast; - this.typeCheckFunctionDeclaration(funcDecl, TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */), funcDecl.identifier, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.getType(funcDecl), funcDecl.block, context); + this.typeCheckAnyFunctionDeclaration(funcDecl, TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */), funcDecl.identifier, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, context); return; } case 219 /* SimpleArrowFunctionExpression */: - this.typeCheckSimpleArrowFunctionExpression(ast, context); + this.typeCheckSimpleArrowFunctionExpression(ast, isContextuallyTyped, context); return; case 218 /* ParenthesizedArrowFunctionExpression */: - this.typeCheckParenthesizedArrowFunctionExpression(ast, context); + this.typeCheckParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); return; case 214 /* ArrayLiteralExpression */: @@ -43758,36 +44908,112 @@ var TypeScript; PullTypeResolver.prototype.resolveNameExpression = function (nameAST, context) { var nameSymbol = this.getSymbolForAST(nameAST, context); - var foundCached = nameSymbol != null; + var foundCached = nameSymbol !== null; if (!foundCached || this.canTypeCheckAST(nameAST, context)) { if (this.canTypeCheckAST(nameAST, context)) { this.typeCheckNameExpression(nameAST, context); } - nameSymbol = this.computeNameExpression(nameAST, context, true); + nameSymbol = this.computeNameExpression(nameAST, context); } this.resolveDeclaredSymbol(nameSymbol, context); - if (nameSymbol && (nameSymbol.type != this.semanticInfoChain.anyTypeSymbol || nameSymbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { + if (nameSymbol && (nameSymbol.type !== this.semanticInfoChain.anyTypeSymbol || nameSymbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { this.setSymbolForAST(nameAST, nameSymbol, context); } return nameSymbol; }; - PullTypeResolver.prototype.isSomeFunctionScope = function (declPath) { - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - if (decl.kind & 1032192 /* SomeFunction */) { - return true; - } + PullTypeResolver.prototype.isInEnumDecl = function (decl) { + if (decl.kind & 64 /* Enum */) { + return true; } + var declPath = decl.getParentPath(); + + var disallowedKinds = 164 /* SomeContainer */ | 58728795 /* SomeType */; + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + + if (decl.kind & 64 /* Enum */) { + return true; + } + + if (decl.kind & disallowedKinds) { + return false; + } + } return false; }; - PullTypeResolver.prototype.computeNameExpression = function (nameAST, context, reportDiagnostics) { + PullTypeResolver.prototype.getSomeInnermostFunctionScopeDecl = function (declPath) { + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + if (decl.kind & 1032192 /* SomeFunction */) { + return decl; + } + } + + return null; + }; + + PullTypeResolver.prototype.isFromFunctionScope = function (nameSymbol, functionScopeDecl) { + var _this = this; + return TypeScript.ArrayUtilities.any(nameSymbol.getDeclarations(), function (nameSymbolDecl) { + return _this.getSomeInnermostFunctionScopeDecl(nameSymbolDecl.getParentPath()) === functionScopeDecl; + }); + }; + + PullTypeResolver.prototype.findConstructorDeclOfEnclosingType = function (decl) { + var current = decl; + while (current) { + if (TypeScript.hasFlag(current.kind, 4096 /* Property */)) { + var parentDecl = current.getParentDecl(); + if (TypeScript.hasFlag(parentDecl.kind, 8 /* Class */)) { + return TypeScript.ArrayUtilities.lastOrDefault(parentDecl.getChildDecls(), function (decl) { + return TypeScript.hasFlag(decl.kind, 32768 /* ConstructorMethod */); + }); + } + } + + if (TypeScript.hasFlag(current.kind, 164 /* SomeContainer */)) { + return null; + } + + current = current.getParentDecl(); + } + return null; + }; + + PullTypeResolver.prototype.checkNameAsPartOfInitializerExpressionForInstanceMemberVariable = function (nameAST) { + var id = nameAST.valueText(); + if (id.length === 0) { + return null; + } + + var memberVariableDeclarationAST = TypeScript.ASTHelpers.getEnclosingMemberVariableDeclaration(nameAST); + if (memberVariableDeclarationAST) { + var memberVariableDecl = this.semanticInfoChain.getDeclForAST(memberVariableDeclarationAST); + if (!TypeScript.hasFlag(memberVariableDecl.flags, 16 /* Static */)) { + var constructorDecl = this.findConstructorDeclOfEnclosingType(memberVariableDecl); + + if (constructorDecl) { + var childDecls = constructorDecl.searchChildDecls(id, 68147712 /* SomeValue */); + + if (childDecls.length) { + var memberVariableSymbol = memberVariableDecl.getSymbol(); + + return this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, [memberVariableSymbol.getScopedName(constructorDecl.getSymbol()), nameAST.text()]); + } + } + } + } + return null; + }; + + PullTypeResolver.prototype.computeNameExpression = function (nameAST, context) { var id = nameAST.valueText(); if (id.length === 0) { return this.semanticInfoChain.anyTypeSymbol; @@ -43796,37 +45022,47 @@ var TypeScript; var nameSymbol = null; var enclosingDecl = this.getEnclosingDeclForAST(nameAST); - if (TypeScript.isDeclarationASTOrDeclarationNameAST(nameAST)) { + if (TypeScript.hasFlag(enclosingDecl.flags, 8388608 /* PropertyParameter */)) { + var valueDecl = enclosingDecl.getValueDecl(); + if (valueDecl && TypeScript.hasFlag(valueDecl.kind, 2048 /* Parameter */)) { + enclosingDecl = valueDecl; + } + } + + var diagnosticForInitializer = this.checkNameAsPartOfInitializerExpressionForInstanceMemberVariable(nameAST); + + if (TypeScript.ASTHelpers.isDeclarationASTOrDeclarationNameAST(nameAST)) { nameSymbol = this.semanticInfoChain.getDeclForAST(nameAST.parent).getSymbol(); } var declPath = enclosingDecl.getParentPath(); if (!nameSymbol) { - var nameSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); + var searchKind = 68147712 /* SomeValue */; + + if (!this.isInEnumDecl(enclosingDecl)) { + searchKind = searchKind & ~(67108864 /* EnumMember */); + } + + var nameSymbol = this.getSymbolFromDeclPath(id, declPath, searchKind); } - if (!nameSymbol && id === "arguments" && this.isSomeFunctionScope(declPath)) { - nameSymbol = this.cachedFunctionArgumentsSymbol(); - - this.resolveDeclaredSymbol(this.cachedIArgumentsInterfaceType(), context); - } - - if (!nameSymbol) { - nameSymbol = this.getSymbolFromDeclPath(id, declPath, 128 /* TypeAlias */); - - if (nameSymbol && !nameSymbol.isAlias()) { - nameSymbol = null; + if (id === "arguments") { + var functionScopeDecl = this.getSomeInnermostFunctionScopeDecl(declPath); + if (functionScopeDecl) { + if (!nameSymbol || !this.isFromFunctionScope(nameSymbol, functionScopeDecl)) { + nameSymbol = this.cachedFunctionArgumentsSymbol(); + this.resolveDeclaredSymbol(this.cachedIArgumentsInterfaceType(), context); + } } } if (!nameSymbol) { - if (!reportDiagnostics) { - return null; - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.text()])); - return this.getNewErrorTypeSymbol(id); - } + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.text()])); + return this.getNewErrorTypeSymbol(id); + } else if (diagnosticForInitializer) { + context.postDiagnostic(diagnosticForInitializer); + return this.getNewErrorTypeSymbol(id); } var nameDeclaration = nameSymbol.getDeclarations()[0]; @@ -43835,22 +45071,26 @@ var TypeScript; var enclosingFunctionAST = this.semanticInfoChain.getASTForDecl(nameParentDecl); var currentParameterIndex = this.getCurrentParameterIndexForFunction(nameAST, enclosingFunctionAST); - var parameterList = TypeScript.getParameterList(enclosingFunctionAST); + var parameterList = TypeScript.ASTHelpers.getParameterList(enclosingFunctionAST); if (currentParameterIndex >= 0) { - var foundMatchingParameter = false; + var matchingParameter; if (parameterList) { for (var i = 0; i <= currentParameterIndex; i++) { var candidateParameter = parameterList.parameters.nonSeparatorAt(i); if (candidateParameter && candidateParameter.identifier.valueText() === id) { - foundMatchingParameter = true; + matchingParameter = candidateParameter; + break; } } } - if (!foundMatchingParameter) { + if (!matchingParameter) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, [parameterList.parameters.nonSeparatorAt(currentParameterIndex).identifier.text(), nameAST.text()])); return this.getNewErrorTypeSymbol(id); + } else if (matchingParameter === TypeScript.ASTHelpers.getEnclosingParameterForInitializer(nameAST)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Parameter_0_cannot_be_referenced_in_its_initializer, [parameterList.parameters.nonSeparatorAt(currentParameterIndex).identifier.text()])); + return this.getNewErrorTypeSymbol(id); } } } @@ -43860,7 +45100,7 @@ var TypeScript; if (nameSymbol.isType() && nameSymbol.isAlias()) { aliasSymbol = nameSymbol; if (!this.inTypeQuery(nameAST)) { - aliasSymbol.setIsUsedAsValue(true); + aliasSymbol.setIsUsedAsValue(); } this.resolveDeclaredSymbol(nameSymbol, context); @@ -43885,7 +45125,7 @@ var TypeScript; }; PullTypeResolver.prototype.getCurrentParameterIndexForFunction = function (parameter, funcDecl) { - var parameterList = TypeScript.getParameterList(funcDecl); + var parameterList = TypeScript.ASTHelpers.getParameterList(funcDecl); if (parameterList) { while (parameter && parameter.parent) { if (parameter.parent.parent === parameterList) { @@ -43905,7 +45145,7 @@ var TypeScript; PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, expression, name, context) { var symbol = this.getSymbolForAST(dottedNameAST, context); - var foundCached = symbol != null; + var foundCached = symbol !== null; if (!foundCached || this.canTypeCheckAST(dottedNameAST, context)) { var canTypeCheckDottedNameAST = this.canTypeCheckAST(dottedNameAST, context); @@ -43918,7 +45158,7 @@ var TypeScript; this.resolveDeclaredSymbol(symbol, context); - if (symbol && (symbol.type != this.semanticInfoChain.anyTypeSymbol || symbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { + if (symbol && (symbol.type !== this.semanticInfoChain.anyTypeSymbol || symbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { this.setSymbolForAST(dottedNameAST, symbol, context); this.setSymbolForAST(name, symbol, context); } @@ -43933,17 +45173,23 @@ var TypeScript; } var lhs = this.resolveAST(expression, false, context); + return this.computeDottedNameExpressionFromLHS(lhs, expression, name, context, checkSuperPrivateAndStaticAccess); + }; + + PullTypeResolver.prototype.computeDottedNameExpressionFromLHS = function (lhs, expression, name, context, checkSuperPrivateAndStaticAccess) { + var rhsName = name.valueText(); + if (rhsName.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + var lhsType = lhs.type; if (lhs.isAlias()) { + var lhsAlias = lhs; if (!this.inTypeQuery(expression)) { - lhs.setIsUsedAsValue(true); + lhsAlias.setIsUsedAsValue(); } - lhsType = lhs.getExportAssignedTypeSymbol(); - } - - if (this.isAnyOrEquivalent(lhsType)) { - return lhsType; + lhsType = lhsAlias.getExportAssignedTypeSymbol(); } if (lhsType.isAlias()) { @@ -43958,7 +45204,7 @@ var TypeScript; if (!lhsType.isResolved) { var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); - if (potentiallySpecializedType != lhsType) { + if (potentiallySpecializedType !== lhsType) { if (!lhs.isType()) { context.setTypeInContext(lhs, potentiallySpecializedType); } @@ -43975,47 +45221,37 @@ var TypeScript; } } - if (lhsType.isTypeParameter()) { - lhsType = this.substituteUpperBoundForType(lhsType); + var originalLhsTypeForErrorReporting = lhsType; + + lhsType = this.getApparentType(lhsType).widenedType(this, expression, context); + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; } - if ((lhsType === this.semanticInfoChain.numberTypeSymbol || lhsType.isEnum()) && this.cachedNumberInterfaceType()) { - lhsType = this.cachedNumberInterfaceType(); - } else if (lhsType === this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { - lhsType = this.cachedStringInterfaceType(); - } else if (lhsType === this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { - lhsType = this.cachedBooleanInterfaceType(); - } - - var nameSymbol = this.getMemberSymbol(rhsName, 68147712 /* SomeValue */, lhsType); + var nameSymbol = this._getNamedPropertySymbolOfAugmentedType(rhsName, lhsType); if (!nameSymbol) { - if ((lhsType.getCallSignatures().length || lhsType.getConstructSignatures().length) && this.cachedFunctionInterfaceType()) { - nameSymbol = this.getMemberSymbol(rhsName, 68147712 /* SomeValue */, this.cachedFunctionInterfaceType()); - } else if (lhsType.kind === 32 /* DynamicModule */) { + if (lhsType.kind === 32 /* DynamicModule */) { var container = lhsType; var associatedInstance = container.getInstanceSymbol(); if (associatedInstance) { var instanceType = associatedInstance.type; - nameSymbol = this.getMemberSymbol(rhsName, 68147712 /* SomeValue */, instanceType); + nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, instanceType); } } else { var associatedType = lhsType.getAssociatedContainerType(); if (associatedType && !associatedType.isClass()) { - nameSymbol = this.getMemberSymbol(rhsName, 68147712 /* SomeValue */, associatedType); + nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, associatedType); } } - if (!nameSymbol && !lhsType.isPrimitive() && this.cachedObjectInterfaceType()) { - nameSymbol = this.getMemberSymbol(rhsName, 68147712 /* SomeValue */, this.cachedObjectInterfaceType()); - } - if (!nameSymbol) { var enclosingDecl = this.getEnclosingDeclForAST(expression); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [name.text(), lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [name.text(), originalLhsTypeForErrorReporting.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); return this.getNewErrorTypeSymbol(rhsName); } } @@ -44055,8 +45291,8 @@ var TypeScript; var onLeftOfDot = this.isLeftSideOfQualifiedName(nameAST); - var kindToCheckFirst = onLeftOfDot ? 164 /* SomeContainer */ : 58728539 /* SomeType */; - var kindToCheckSecond = onLeftOfDot ? 58728539 /* SomeType */ : 164 /* SomeContainer */; + var kindToCheckFirst = onLeftOfDot ? 164 /* SomeContainer */ : 58728795 /* SomeType */; + var kindToCheckSecond = onLeftOfDot ? 58728795 /* SomeType */ : 164 /* SomeContainer */; var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); @@ -44080,11 +45316,11 @@ var TypeScript; } if (typeNameSymbol.isTypeParameter()) { - if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */) && (enclosingDecl.flags & 16 /* Static */)) { + if (this.isInStaticMemberContext(enclosingDecl)) { var parentDecl = typeNameSymbol.getDeclarations()[0].getParentDecl(); - if (parentDecl.kind == 8 /* Class */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Static_methods_cannot_reference_class_type_parameters)); + if (parentDecl.kind === 8 /* Class */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Static_members_cannot_reference_class_type_parameters)); return this.getNewErrorTypeSymbol(); } } @@ -44097,6 +45333,22 @@ var TypeScript; return typeNameSymbol; }; + PullTypeResolver.prototype.isInStaticMemberContext = function (decl) { + while (decl) { + if (TypeScript.hasFlag(decl.kind, 1032192 /* SomeFunction */ | 4096 /* Property */) && TypeScript.hasFlag(decl.flags, 16 /* Static */)) { + return true; + } + + if (TypeScript.hasFlag(decl.kind, 164 /* SomeContainer */)) { + return false; + } + + decl = decl.getParentDecl(); + } + + return false; + }; + PullTypeResolver.prototype.isLeftSideOfQualifiedName = function (ast) { return ast && ast.parent && ast.parent.kind() === 121 /* QualifiedName */ && ast.parent.left === ast; }; @@ -44113,9 +45365,18 @@ var TypeScript; } if (genericTypeSymbol.isAlias()) { + if (this.inClassExtendsHeritageClause(genericTypeAST) && !this.inTypeArgumentList(genericTypeAST)) { + genericTypeSymbol.setIsUsedAsValue(); + } genericTypeSymbol = genericTypeSymbol.getExportAssignedTypeSymbol(); } + var typeParameters = genericTypeSymbol.getTypeParameters(); + if (typeParameters.length === 0) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(genericTypeAST, TypeScript.DiagnosticCode.Type_0_does_not_have_type_parameters, [genericTypeSymbol.toString()])); + return this.getNewErrorTypeSymbol(); + } + var typeArgs = []; if (genericTypeAST.typeArgumentList && genericTypeAST.typeArgumentList.typeArguments.nonSeparatorCount()) { @@ -44128,9 +45389,7 @@ var TypeScript; } } - var typeParameters = genericTypeSymbol.getTypeParameters(); - - if (typeArgs.length && typeArgs.length != typeParameters.length) { + if (typeArgs.length && typeArgs.length !== typeParameters.length) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(genericTypeAST, TypeScript.DiagnosticCode.Generic_type_0_requires_1_type_argument_s, [genericTypeSymbol.toString(), genericTypeSymbol.getTypeParameters().length])); return this.getNewErrorTypeSymbol(); } @@ -44177,7 +45436,7 @@ var TypeScript; if (typeConstraint) { if (typeConstraint.isTypeParameter()) { for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { - if (typeParameters[j] == typeConstraint) { + if (typeParameters[j] === typeConstraint) { typeConstraint = typeArgs[j]; } } @@ -44196,6 +45455,7 @@ var TypeScript; if (typeArg.inResolution || (typeArg.isTypeReference() && typeArg.referencedTypeSymbol.inResolution)) { return specializedSymbol; } + if (!this.sourceIsAssignableToTarget(typeArg, typeConstraint, genericTypeAST, context)) { var enclosingSymbol = this.getEnclosingSymbolForAST(genericTypeAST); context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(genericTypeAST, TypeScript.DiagnosticCode.Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2, [typeArg.toString(enclosingSymbol, true), typeConstraint.toString(enclosingSymbol, true), typeParameters[iArg].toString(enclosingSymbol, true)])); @@ -44227,6 +45487,10 @@ var TypeScript; return symbol; }; + PullTypeResolver.prototype.isLastNameOfModuleNameModuleReference = function (ast) { + return ast.kind() === 11 /* IdentifierName */ && ast.parent && ast.parent.kind() === 121 /* QualifiedName */ && ast.parent.right === ast && ast.parent.parent && ast.parent.parent.kind() === 246 /* ModuleNameModuleReference */; + }; + PullTypeResolver.prototype.computeQualifiedName = function (dottedNameAST, context) { var rhsName = dottedNameAST.right.valueText(); if (rhsName.length === 0) { @@ -44240,7 +45504,7 @@ var TypeScript; if (this.inClassExtendsHeritageClause(dottedNameAST) && !this.inTypeArgumentList(dottedNameAST)) { if (lhs.isAlias()) { - lhs.setIsUsedAsValue(true); + lhs.setIsUsedAsValue(); } } @@ -44254,15 +45518,20 @@ var TypeScript; var onLeftOfDot = this.isLeftSideOfQualifiedName(dottedNameAST); var isNameOfModule = dottedNameAST.parent.kind() === 130 /* ModuleDeclaration */ && dottedNameAST.parent.name === dottedNameAST; - var memberKind = (onLeftOfDot || isNameOfModule) ? 164 /* SomeContainer */ : 58728539 /* SomeType */; - var childTypeSymbol = this.getMemberSymbol(rhsName, memberKind, lhsType); + var memberKind = (onLeftOfDot || isNameOfModule) ? 164 /* SomeContainer */ : 58728795 /* SomeType */; + + var childTypeSymbol = this.getNamedPropertySymbol(rhsName, memberKind, lhsType); + + if (!childTypeSymbol && !isNameOfModule && this.isLastNameOfModuleNameModuleReference(dottedNameAST.right)) { + childTypeSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, lhsType); + } if (!childTypeSymbol && lhsType.isContainer()) { var exportedContainer = lhsType.getExportAssignedContainerSymbol(); if (exportedContainer) { - childTypeSymbol = this.getMemberSymbol(rhsName, memberKind, exportedContainer); + childTypeSymbol = this.getNamedPropertySymbol(rhsName, memberKind, exportedContainer); } } @@ -44281,7 +45550,7 @@ var TypeScript; var enclosingSymbolType = parentDecl.getSymbol().type; if (enclosingSymbolType === lhsType) { - childTypeSymbol = this.getMemberSymbol(rhsName, memberKind, lhsType); + childTypeSymbol = this.getNamedPropertySymbol(rhsName, memberKind, lhsType); } } } @@ -44316,12 +45585,12 @@ var TypeScript; if (contextualFunctionTypeSymbol) { this.resolveDeclaredSymbol(contextualFunctionTypeSymbol, context); var callSignatures = contextualFunctionTypeSymbol.getCallSignatures(); - var exactlyOneCallSignature = callSignatures && callSignatures.length == 1; + var exactlyOneCallSignature = callSignatures && callSignatures.length === 1; if (!exactlyOneCallSignature) { return false; } - var callSignatureIsGeneric = callSignatures[0].typeParameters && callSignatures[0].typeParameters.length > 0; + var callSignatureIsGeneric = callSignatures[0].getTypeParameters().length > 0; return !callSignatureIsGeneric; } @@ -44358,36 +45627,7 @@ var TypeScript; assigningFunctionSignature = context.getContextualType().getCallSignatures()[0]; } - if (parameters) { - var contextParams = []; - - if (assigningFunctionSignature) { - contextParams = assigningFunctionSignature.parameters; - } - - var contextualParametersCount = contextParams.length; - for (var i = 0, n = parameters.length; i < n; i++) { - var actualParameterIsVarArgParameter = (i === (n - 1)) && parameters.lastParameterIsRest(); - var correspondingContextualParameter = null; - var contextualParameterType = null; - - if (i < contextualParametersCount) { - correspondingContextualParameter = contextParams[i]; - } else if (contextualParametersCount && contextParams[contextualParametersCount - 1].isVarArg) { - correspondingContextualParameter = contextParams[contextualParametersCount - 1]; - } - - if (correspondingContextualParameter) { - if (correspondingContextualParameter.isVarArg === actualParameterIsVarArgParameter) { - contextualParameterType = correspondingContextualParameter.type; - } else if (correspondingContextualParameter.isVarArg) { - contextualParameterType = correspondingContextualParameter.type.getElementType(); - } - } - - this.resolveFunctionExpressionParameter(parameters.astAt(i), parameters.identifierAt(i), parameters.typeAt(i), parameters.initializerAt(i), contextualParameterType, functionDecl, context); - } - } + this.resolveAnyFunctionExpressionParameters(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, isContextuallyTyped, context); if (returnTypeAnnotation) { signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); @@ -44396,10 +45636,9 @@ var TypeScript; var returnType = assigningFunctionSignature.returnType; if (returnType) { - context.pushContextualType(returnType, context.inProvisionalResolution(), null); - + context.propagateContextualType(returnType); this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, true, functionDecl, context); - context.popContextualType(); + context.popAnyContextualType(); } else { signature.returnType = this.semanticInfoChain.anyTypeSymbol; @@ -44422,21 +45661,63 @@ var TypeScript; funcDeclSymbol.setResolved(); if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckAnyFunctionExpression(funcDeclAST, typeParameters, returnTypeAnnotation, block, bodyExpression, context); + this.typeCheckAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context); } return funcDeclSymbol; }; - PullTypeResolver.prototype.typeCheckSimpleArrowFunctionExpression = function (arrowFunction, context) { - return this.typeCheckAnyFunctionExpression(arrowFunction, null, null, arrowFunction.block, arrowFunction.expression, context); + PullTypeResolver.prototype.resolveAnyFunctionExpressionParameters = function (funcDeclAST, typeParameters, parameters, returnTypeAnnotation, isContextuallyTyped, context) { + if (!parameters) { + return; + } + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var contextParams = []; + + var assigningFunctionSignature = null; + if (isContextuallyTyped && this.shouldContextuallyTypeAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, context)) { + assigningFunctionSignature = context.getContextualType().getCallSignatures()[0]; + } + + if (assigningFunctionSignature) { + contextParams = assigningFunctionSignature.parameters; + } + + var contextualParametersCount = contextParams.length; + for (var i = 0, n = parameters.length; i < n; i++) { + var actualParameterIsVarArgParameter = (i === (n - 1)) && parameters.lastParameterIsRest(); + var correspondingContextualParameter = null; + var contextualParameterType = null; + + if (i < contextualParametersCount) { + correspondingContextualParameter = contextParams[i]; + } else if (contextualParametersCount && contextParams[contextualParametersCount - 1].isVarArg) { + correspondingContextualParameter = contextParams[contextualParametersCount - 1]; + } + + if (correspondingContextualParameter) { + if (correspondingContextualParameter.isVarArg === actualParameterIsVarArgParameter) { + contextualParameterType = correspondingContextualParameter.type; + } else if (correspondingContextualParameter.isVarArg) { + contextualParameterType = correspondingContextualParameter.type.getElementType(); + } + } + + this.resolveFunctionExpressionParameter(parameters.astAt(i), parameters.identifierAt(i), parameters.typeAt(i), parameters.initializerAt(i), contextualParameterType, functionDecl, context); + } }; - PullTypeResolver.prototype.typeCheckParenthesizedArrowFunctionExpression = function (arrowFunction, context) { - return this.typeCheckAnyFunctionExpression(arrowFunction, arrowFunction.callSignature.typeParameterList, TypeScript.getType(arrowFunction), arrowFunction.block, arrowFunction.expression, context); + PullTypeResolver.prototype.typeCheckSimpleArrowFunctionExpression = function (arrowFunction, isContextuallyTyped, context) { + return this.typeCheckAnyFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), null, arrowFunction.block, arrowFunction.expression, isContextuallyTyped, context); }; - PullTypeResolver.prototype.typeCheckAnyFunctionExpression = function (funcDeclAST, typeParameters, returnTypeAnnotation, block, bodyExpression, context) { + PullTypeResolver.prototype.typeCheckParenthesizedArrowFunctionExpression = function (arrowFunction, isContextuallyTyped, context) { + return this.typeCheckAnyFunctionExpression(arrowFunction, arrowFunction.callSignature.typeParameterList, TypeScript.ASTHelpers.parametersFromParameterList(arrowFunction.callSignature.parameterList), TypeScript.ASTHelpers.getType(arrowFunction), arrowFunction.block, arrowFunction.expression, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.typeCheckAnyFunctionExpression = function (funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context) { var _this = this; this.setTypeChecked(funcDeclAST, context); @@ -44453,27 +45734,19 @@ var TypeScript; } } - context.pushContextualType(null, context.inProvisionalResolution(), null); + this.resolveAnyFunctionExpressionParameters(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, isContextuallyTyped, context); + + context.pushNewContextualType(null); if (block) { this.resolveAST(block, false, context); } else { var bodyExpressionType = this.resolveReturnExpression(bodyExpression, functionDecl, context); this.typeCheckReturnExpression(bodyExpression, bodyExpressionType, functionDecl, context); } - context.popContextualType(); - var hasReturn = (functionDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; + context.popAnyContextualType(); - if (block && returnTypeAnnotation != null && !hasReturn) { - var isVoidOrAny = this.isAnyOrEquivalent(returnTypeSymbol) || returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol; - - if (!isVoidOrAny && !(block.statements.childCount() > 0 && block.statements.childAt(0).kind() === 157 /* ThrowStatement */)) { - var funcName = functionDecl.getDisplayName(); - funcName = funcName ? "'" + funcName + "'" : "expression"; - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Function_0_declared_a_non_void_return_type_but_has_no_return_expression, [funcName])); - } - } + this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(functionDecl, returnTypeAnnotation, returnTypeSymbol, block, context); this.validateVariableDeclarationGroups(functionDecl, context); @@ -44587,9 +45860,11 @@ var TypeScript; var current = ast; while (current) { switch (current.kind()) { - case 137 /* ConstructorDeclaration */: - var constructorDecl = current; - return previous === constructorDecl.parameterList; + case 142 /* CallSignature */: + var callSignature = current; + if (previous === callSignature.parameterList && callSignature.parent.kind() === 137 /* ConstructorDeclaration */) { + return true; + } case 131 /* ClassDeclaration */: case 130 /* ModuleDeclaration */: @@ -44602,6 +45877,13 @@ var TypeScript; return false; }; + PullTypeResolver.prototype.isFunctionAccessorOrNonArrowFunctionExpression = function (decl) { + if (decl.kind === 262144 /* GetAccessor */ || decl.kind === 524288 /* SetAccessor */) { + return true; + } + + return this.isFunctionOrNonArrowFunctionExpression(decl); + }; PullTypeResolver.prototype.isFunctionOrNonArrowFunctionExpression = function (decl) { if (decl.kind === 16384 /* Function */) { @@ -44622,7 +45904,7 @@ var TypeScript; } for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { - if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { + if (this.isFunctionAccessorOrNonArrowFunctionExpression(currentDecl)) { return; } else if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { if (currentDecl.getParentDecl() === null) { @@ -44631,6 +45913,9 @@ var TypeScript; context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_within_module_bodies)); return; } + } else if (currentDecl.kind === 64 /* Enum */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_current_location)); + return; } else if (currentDecl.kind === 32768 /* ConstructorMethod */) { if (this.inArgumentListOfSuperInvocation(thisExpression) && this.superCallMustBeFirstStatementInConstructor(currentDecl)) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_current_location)); @@ -44745,29 +46030,22 @@ var TypeScript; return; } } - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class)); return; } else { - for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { - if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { - break; - } else if (currentDecl.kind === 32768 /* ConstructorMethod */) { - var classDecl = currentDecl.getParentDecl(); - - if (!this.enclosingClassIsDerived(classDecl)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.super_cannot_be_referenced_in_non_derived_classes)); - return; - } else if (this.inConstructorParameterList(ast)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.super_cannot_be_referenced_in_constructor_arguments)); - return; - } + if (enclosingDecl.kind === 32768 /* ConstructorMethod */) { + var classDecl = enclosingDecl.getParentDecl(); + if (!this.enclosingClassIsDerived(classDecl)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.super_cannot_be_referenced_in_non_derived_classes)); + return; + } else if (this.inConstructorParameterList(ast)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.super_cannot_be_referenced_in_constructor_arguments)); return; } + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors)); } - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors)); } }; @@ -44776,17 +46054,18 @@ var TypeScript; }; PullTypeResolver.prototype.resolveFunctionPropertyAssignment = function (funcProp, isContextuallyTyped, context) { - return this.resolveAnyFunctionExpression(funcProp, funcProp.callSignature.typeParameterList, TypeScript.Parameters.fromParameterList(funcProp.callSignature.parameterList), TypeScript.getType(funcProp), funcProp.block, null, isContextuallyTyped, context); + return this.resolveAnyFunctionExpression(funcProp, funcProp.callSignature.typeParameterList, TypeScript.ASTHelpers.parametersFromParameterList(funcProp.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcProp), funcProp.block, null, isContextuallyTyped, context); }; PullTypeResolver.prototype.typeCheckFunctionPropertyAssignment = function (funcProp, isContextuallyTyped, context) { - this.typeCheckAnyFunctionExpression(funcProp, funcProp.callSignature.typeParameterList, TypeScript.getType(funcProp), funcProp.block, null, context); + this.typeCheckAnyFunctionExpression(funcProp, funcProp.callSignature.typeParameterList, TypeScript.ASTHelpers.parametersFromParameterList(funcProp.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcProp), funcProp.block, null, isContextuallyTyped, context); }; PullTypeResolver.prototype.resolveObjectLiteralExpression = function (expressionAST, isContextuallyTyped, context, additionalResults) { var symbol = this.getSymbolForAST(expressionAST, context); + var hasResolvedSymbol = symbol && symbol.isResolved; - if (!symbol || additionalResults || this.canTypeCheckAST(expressionAST, context)) { + if (!hasResolvedSymbol || additionalResults || this.canTypeCheckAST(expressionAST, context)) { if (this.canTypeCheckAST(expressionAST, context)) { this.setTypeChecked(expressionAST, context); } @@ -44810,7 +46089,7 @@ var TypeScript; var decl = this.semanticInfoChain.getDeclForAST(propertyAssignment); TypeScript.Debug.assert(decl); - if (propertyAssignment.kind() == 240 /* SimplePropertyAssignment */) { + if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { if (!isUsingExistingSymbol) { memberSymbol = new TypeScript.PullSymbol(assignmentText.memberName, 4096 /* Property */); memberSymbol.addDeclaration(decl); @@ -44826,8 +46105,9 @@ var TypeScript; } if (!isUsingExistingSymbol && !isAccessor) { - if (objectLiteralTypeSymbol.findMember(memberSymbol.name, true)) { - pullTypeContext.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(propertyAssignment, TypeScript.DiagnosticCode.Duplicate_identifier_0, [assignmentText.actualText])); + var existingMember = objectLiteralTypeSymbol.findMember(memberSymbol.name, true); + if (existingMember) { + pullTypeContext.postDiagnostic(this.semanticInfoChain.duplicateIdentifierDiagnosticFromAST(propertyAssignment, assignmentText.actualText, existingMember.getDeclarations()[0].ast())); } objectLiteralTypeSymbol.addMember(memberSymbol); @@ -44848,9 +46128,10 @@ var TypeScript; var id = this.getPropertyAssignmentName(propertyAssignment); var memberSymbol = boundMemberSymbols[i]; + var contextualMemberType = null; if (objectLiteralContextualType) { - assigningSymbol = this.getMemberSymbol(memberSymbol.name, 68147712 /* SomeValue */, objectLiteralContextualType); + assigningSymbol = this.getNamedPropertySymbol(memberSymbol.name, 68147712 /* SomeValue */, objectLiteralContextualType); if (!assigningSymbol) { if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { @@ -44863,8 +46144,8 @@ var TypeScript; if (assigningSymbol) { this.resolveDeclaredSymbol(assigningSymbol, pullTypeContext); - var contextualMemberType = assigningSymbol.kind === 4194304 /* IndexSignature */ ? assigningSymbol.returnType : assigningSymbol.type; - pullTypeContext.pushContextualType(contextualMemberType, pullTypeContext.inProvisionalResolution(), null); + contextualMemberType = assigningSymbol.kind === 4194304 /* IndexSignature */ ? assigningSymbol.returnType : assigningSymbol.type; + pullTypeContext.propagateContextualType(contextualMemberType); acceptedContextualType = true; @@ -44874,32 +46155,31 @@ var TypeScript; } } - var propertySymbol = this.resolveAST(propertyAssignment, contextualMemberType != null, pullTypeContext); - var memberExpr = this.widenType(propertySymbol.type, propertyAssignment, pullTypeContext); + var memberSymbolType = this.resolveAST(propertyAssignment, contextualMemberType !== null, pullTypeContext).type; - if (memberExpr.type) { - if (memberExpr.type.isGeneric()) { + if (memberSymbolType) { + if (memberSymbolType.isGeneric()) { objectLiteralTypeSymbol.setHasGenericMember(); } if (stringIndexerSignature) { - allMemberTypes.push(memberExpr.type); + allMemberTypes.push(memberSymbolType); } if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { - allNumericMemberTypes.push(memberExpr.type); + allNumericMemberTypes.push(memberSymbolType); } } if (acceptedContextualType) { - pullTypeContext.popContextualType(); + pullTypeContext.popAnyContextualType(); } var isAccessor = propertyAssignment.kind() === 140 /* SetAccessor */ || propertyAssignment.kind() === 139 /* GetAccessor */; - if (!isUsingExistingSymbol) { + if (!memberSymbol.isResolved) { if (isAccessor) { - this.setSymbolForAST(id, memberExpr, pullTypeContext); + this.setSymbolForAST(id, memberSymbolType, pullTypeContext); } else { - pullTypeContext.setTypeInContext(memberSymbol, memberExpr.type); + pullTypeContext.setTypeInContext(memberSymbol, memberSymbolType); memberSymbol.setResolved(); this.setSymbolForAST(id, memberSymbol, pullTypeContext); @@ -44916,7 +46196,7 @@ var TypeScript; var isUsingExistingSymbol = !!typeSymbol; if (!typeSymbol) { - typeSymbol = new TypeScript.PullTypeSymbol("", 16 /* Interface */); + typeSymbol = new TypeScript.PullTypeSymbol("", 256 /* ObjectLiteral */); typeSymbol.addDeclaration(objectLitDecl); this.setSymbolForAST(objectLitAST, typeSymbol, context); objectLitDecl.setSymbol(typeSymbol); @@ -44936,17 +46216,18 @@ var TypeScript; var allNumericMemberTypes = null; if (contextualType) { - var indexSignatures = this.getBothKindsOfIndexSignatures(contextualType, context); + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); stringIndexerSignature = indexSignatures.stringSignature; numericIndexerSignature = indexSignatures.numericSignature; + var inInferentialTyping = context.isInferentiallyTyping(); if (stringIndexerSignature) { - allMemberTypes = [stringIndexerSignature.returnType]; + allMemberTypes = inInferentialTyping ? [] : [stringIndexerSignature.returnType]; } if (numericIndexerSignature) { - allNumericMemberTypes = [numericIndexerSignature.returnType]; + allNumericMemberTypes = inInferentialTyping ? [] : [numericIndexerSignature.returnType]; } } @@ -44994,8 +46275,8 @@ var TypeScript; } }; var decl = objectLiteralSymbol.getDeclarations()[0]; - var indexerReturnType = this.widenType(this.findBestCommonType(typeCollection, context)); - if (indexerReturnType == contextualIndexSignature.returnType) { + var indexerReturnType = this.findBestCommonType(typeCollection, context).widenedType(this, null, context); + if (indexerReturnType === contextualIndexSignature.returnType) { objectLiteralSymbol.addIndexSignature(contextualIndexSignature); } else { this.semanticInfoChain.addSyntheticIndexSignature(decl, objectLiteralSymbol, this.getASTForDecl(decl), contextualIndexSignature.parameters[0].name, contextualIndexSignature.parameters[0].type, indexerReturnType); @@ -45030,7 +46311,7 @@ var TypeScript; this.resolveDeclaredSymbol(contextualType, context); if (contextualType) { - var indexSignatures = this.getBothKindsOfIndexSignatures(contextualType, context); + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); if (indexSignatures.numericSignature) { contextualElementType = indexSignatures.numericSignature.returnType; } @@ -45039,7 +46320,7 @@ var TypeScript; if (elements) { if (contextualElementType) { - context.pushContextualType(contextualElementType, context.inProvisionalResolution(), null); + context.propagateContextualType(contextualElementType); } for (var i = 0, n = elements.nonSeparatorCount(); i < n; i++) { @@ -45047,7 +46328,7 @@ var TypeScript; } if (contextualElementType) { - context.popContextualType(); + context.popAnyContextualType(); } } @@ -45055,7 +46336,8 @@ var TypeScript; elementType = elementTypes[0]; } var collection; - if (contextualElementType) { + + if (contextualElementType && !context.isInferentiallyTyping()) { if (!elementType) { elementType = contextualElementType; } @@ -45085,19 +46367,7 @@ var TypeScript; elementType = this.semanticInfoChain.undefinedTypeSymbol; } - var arraySymbol = elementType.getArrayType(); - - if (!arraySymbol) { - arraySymbol = this.createInstantiatedType(this.cachedArrayInterfaceType(), [elementType]); - - if (!arraySymbol) { - arraySymbol = this.semanticInfoChain.anyTypeSymbol; - } - - elementType.setArrayType(arraySymbol); - } - - return arraySymbol; + return this.getArrayType(elementType); }; PullTypeResolver.prototype.resolveElementAccessExpression = function (callEx, context) { @@ -45121,6 +46391,8 @@ var TypeScript; var targetTypeSymbol = targetSymbol.type; + targetTypeSymbol = this.getApparentType(targetTypeSymbol); + if (this.isAnyOrEquivalent(targetTypeSymbol)) { return { symbol: targetTypeSymbol }; } @@ -45136,7 +46408,7 @@ var TypeScript; if (callEx.argumentExpression.kind() === 14 /* StringLiteral */ || callEx.argumentExpression.kind() === 13 /* NumericLiteral */) { var memberName = callEx.argumentExpression.kind() === 14 /* StringLiteral */ ? TypeScript.stripStartAndEndQuotes(callEx.argumentExpression.text()) : callEx.argumentExpression.valueText(); - var member = this.getMemberSymbol(memberName, 68147712 /* SomeValue */, targetTypeSymbol); + var member = this._getNamedPropertySymbolOfAugmentedType(memberName, targetTypeSymbol); if (member) { this.resolveDeclaredSymbol(member, context); @@ -45145,11 +46417,7 @@ var TypeScript; } } - if (targetTypeSymbol == this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { - targetTypeSymbol = this.cachedStringInterfaceType(); - } - - var signatures = this.getBothKindsOfIndexSignatures(targetTypeSymbol, context); + var signatures = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(targetTypeSymbol, context); var stringSignature = signatures.stringSignature; var numberSignature = signatures.numericSignature; @@ -45159,6 +46427,9 @@ var TypeScript; } else if (stringSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol || indexType === this.semanticInfoChain.stringTypeSymbol)) { return { symbol: stringSignature.returnType || this.semanticInfoChain.anyTypeSymbol }; } else if (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol || indexType === this.semanticInfoChain.stringTypeSymbol) { + if (this.compilationSettings.noImplicitAny()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(callEx.argumentExpression, TypeScript.DiagnosticCode.Index_signature_of_object_type_implicitly_has_an_any_type)); + } return { symbol: this.semanticInfoChain.anyTypeSymbol }; } else { return { @@ -45168,8 +46439,16 @@ var TypeScript; } }; - PullTypeResolver.prototype.getBothKindsOfIndexSignatures = function (enclosingType, context) { - var signatures = enclosingType.getIndexSignatures(); + PullTypeResolver.prototype.getBothKindsOfIndexSignaturesIncludingAugmentedType = function (enclosingType, context) { + return this._getBothKindsOfIndexSignatures(enclosingType, context, true); + }; + + PullTypeResolver.prototype.getBothKindsOfIndexSignaturesExcludingAugmentedType = function (enclosingType, context) { + return this._getBothKindsOfIndexSignatures(enclosingType, context, false); + }; + + PullTypeResolver.prototype._getBothKindsOfIndexSignatures = function (enclosingType, context, includeAugmentedType) { + var signatures = includeAugmentedType ? enclosingType.getIndexSignaturesOfAugmentedType(this, this.cachedFunctionInterfaceType(), this.cachedObjectInterfaceType()) : enclosingType.getIndexSignatures(); var stringSignature = null; var numberSignature = null; @@ -45208,6 +46487,27 @@ var TypeScript; }; }; + PullTypeResolver.prototype._addUnhiddenSignaturesFromBaseType = function (derivedTypeSignatures, baseTypeSignatures, signaturesBeingAggregated) { + var _this = this; + if (!derivedTypeSignatures) { + signaturesBeingAggregated.push.apply(signaturesBeingAggregated, baseTypeSignatures); + return; + } + + var context = new TypeScript.PullTypeResolutionContext(this); + for (var i = 0; i < baseTypeSignatures.length; i++) { + var baseSignature = baseTypeSignatures[i]; + + var signatureIsHidden = TypeScript.ArrayUtilities.any(derivedTypeSignatures, function (sig) { + return _this.signaturesAreIdenticalWithNewEnclosingTypes(baseSignature, sig, context, false); + }); + + if (!signatureIsHidden) { + signaturesBeingAggregated.push(baseSignature); + } + } + }; + PullTypeResolver.prototype.resolveBinaryAdditionOperation = function (binaryExpression, context) { var lhsExpression = this.resolveAST(binaryExpression.left, false, context); var lhsType = lhsExpression.type; @@ -45215,22 +46515,23 @@ var TypeScript; if (TypeScript.PullHelpers.symbolIsEnum(lhsType)) { lhsType = this.semanticInfoChain.numberTypeSymbol; - } else if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { - if (rhsType != this.semanticInfoChain.nullTypeSymbol && rhsType != this.semanticInfoChain.undefinedTypeSymbol) { - lhsType = rhsType; - } else { - lhsType = this.semanticInfoChain.anyTypeSymbol; - } } if (TypeScript.PullHelpers.symbolIsEnum(rhsType)) { rhsType = this.semanticInfoChain.numberTypeSymbol; - } else if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { - if (lhsType != this.semanticInfoChain.nullTypeSymbol && lhsType != this.semanticInfoChain.undefinedTypeSymbol) { - rhsType = lhsType; + } + + var isLhsTypeNullOrUndefined = lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol; + var isRhsTypeNullOrUndefined = rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol; + + if (isLhsTypeNullOrUndefined) { + if (isRhsTypeNullOrUndefined) { + lhsType = rhsType = this.semanticInfoChain.anyTypeSymbol; } else { - rhsType = this.semanticInfoChain.anyTypeSymbol; + lhsType = rhsType; } + } else if (isRhsTypeNullOrUndefined) { + rhsType = lhsType; } var exprType = null; @@ -45310,13 +46611,13 @@ var TypeScript; var leftType = this.resolveAST(binex.left, isContextuallyTyped, context).type; var rightType = this.resolveAST(binex.right, isContextuallyTyped, context).type; - return this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); + return context.isInferentiallyTyping() ? this.bestCommonTypeOfTwoTypes(leftType, rightType, context) : this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); } else { var leftType = this.resolveAST(binex.left, false, context).type; - context.pushContextualType(leftType, context.inProvisionalResolution(), null); + context.pushNewContextualType(leftType); var rightType = this.resolveAST(binex.right, true, context).type; - context.popContextualType(); + context.popAnyContextualType(); return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); } @@ -45333,7 +46634,7 @@ var TypeScript; }; PullTypeResolver.prototype.computeTypeOfConditionalExpression = function (leftType, rightType, isContextuallyTyped, context) { - if (isContextuallyTyped) { + if (isContextuallyTyped && !context.isInferentiallyTyping()) { var contextualType = context.getContextualType(); return this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); } else { @@ -45373,11 +46674,11 @@ var TypeScript; PullTypeResolver.prototype.conditionExpressionTypesAreValid = function (leftType, rightType, expressionType, isContextuallyTyped, context) { if (isContextuallyTyped) { var contextualType = context.getContextualType(); - if (this.typesAreIdentical(expressionType, leftType) || this.typesAreIdentical(expressionType, rightType) || this.typesAreIdentical(expressionType, contextualType)) { + if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context) || this.typesAreIdentical(expressionType, contextualType, context)) { return true; } } else { - if (this.typesAreIdentical(expressionType, leftType) || this.typesAreIdentical(expressionType, rightType)) { + if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context)) { return true; } } @@ -45414,7 +46715,7 @@ var TypeScript; if (this.canTypeCheckAST(callEx, context)) { this.setTypeChecked(callEx, context); } - if (symbol != this.semanticInfoChain.anyTypeSymbol) { + if (symbol !== this.semanticInfoChain.anyTypeSymbol) { this.setSymbolForAST(callEx, symbol, context); } this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); @@ -45424,7 +46725,7 @@ var TypeScript; } var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (additionalResults && (callResolutionData != additionalResults)) { + if (additionalResults && (callResolutionData !== additionalResults)) { additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; additionalResults.candidateSignature = callResolutionData.candidateSignature; additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; @@ -45446,13 +46747,13 @@ var TypeScript; for (var i = 0; i < len; i++) { var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); + context.pushNewContextualType(contextualType); } - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType != null, context); + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); if (contextualType) { - context.popContextualType(); + context.popAnyContextualType(); contextualType = null; } } @@ -45500,12 +46801,11 @@ var TypeScript; var signatures = isSuperCall ? targetTypeSymbol.getConstructSignatures() : targetTypeSymbol.getCallSignatures(); - if (!signatures.length && (targetTypeSymbol.kind == 33554432 /* ConstructorType */)) { + if (!signatures.length && (targetTypeSymbol.kind === 33554432 /* ConstructorType */)) { this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, [targetTypeSymbol.toString()]), additionalResults, context); } - var typeArgs = null; - var typeReplacementMap = null; + var explicitTypeArgs = null; var couldNotFindGenericOverload = false; var couldNotAssignToConstraint; var constraintDiagnostic = null; @@ -45513,21 +46813,19 @@ var TypeScript; var diagnostics = []; if (callEx.argumentList.typeArgumentList) { - typeArgs = []; + explicitTypeArgs = []; if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - typeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); } } - } else if (isSuperCall && targetTypeSymbol.isGeneric()) { - typeArgs = targetTypeSymbol.getTypeArguments(); } var triedToInferTypeArgs = false; var resolvedSignatures = []; - var inferredTypeArgs; + var inferredOrExplicitTypeArgs; var specializedSignature; var typeParameters; var typeConstraint = null; @@ -45539,86 +46837,61 @@ var TypeScript; couldNotAssignToConstraint = false; if (signatures[i].isGeneric() && typeParameters.length) { - if (typeArgs) { - if (typeArgs.length == typeParameters.length) { - inferredTypeArgs = typeArgs; - } else { - typeArgumentCountDiagnostic = typeArgumentCountDiagnostic || this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Signature_expected_0_type_arguments_got_1_instead, [typeParameters.length, typeArgs.length]); - continue; - } - } else if (!typeArgs && callEx.argumentList.arguments && callEx.argumentList.arguments.nonSeparatorCount()) { - inferredTypeArgs = this.inferArgumentTypesForSignature(signatures[i], new TypeScript.ArgumentInferenceContext(this, callEx.argumentList.arguments), new TypeComparisonInfo(), context); - triedToInferTypeArgs = true; - } else { - inferredTypeArgs = []; + if (isSuperCall && targetTypeSymbol.isGeneric() && !callEx.argumentList.typeArgumentList) { + explicitTypeArgs = signatures[i].returnType.getTypeArguments(); } - if (inferredTypeArgs) { - typeReplacementMap = []; - - if (inferredTypeArgs.length) { - if (inferredTypeArgs.length != typeParameters.length) { - continue; - } - - if (targetTypeReplacementMap) { - for (var symbolID in targetTypeReplacementMap) { - if (targetTypeReplacementMap.hasOwnProperty(symbolID)) { - typeReplacementMap[symbolID] = targetTypeReplacementMap[symbolID]; - } - } - } - - for (var j = 0; j < typeParameters.length; j++) { - typeReplacementMap[typeParameters[j].pullSymbolID] = inferredTypeArgs[j]; - } - for (var j = 0; j < typeParameters.length; j++) { - typeConstraint = typeParameters[j].getConstraint(); - - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var k = 0; k < typeParameters.length && k < inferredTypeArgs.length; k++) { - if (typeParameters[k] == typeConstraint) { - typeConstraint = inferredTypeArgs[k]; - } else { - typeConstraint = this.instantiateType(typeConstraint, typeReplacementMap); - } - } - } else if (typeConstraint.isGeneric()) { - typeConstraint = this.instantiateType(typeConstraint, typeReplacementMap); - } - - if (!this.sourceIsAssignableToTarget(inferredTypeArgs[j], typeConstraint, targetAST, context, null, true)) { - var enclosingSymbol = this.getEnclosingSymbolForAST(targetAST); - constraintDiagnostic = this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2, [inferredTypeArgs[j].toString(enclosingSymbol, true), typeConstraint.toString(enclosingSymbol, true), typeParameters[j].toString(enclosingSymbol, true)]); - couldNotAssignToConstraint = true; - } - - if (couldNotAssignToConstraint) { - break; - } - } - } + if (explicitTypeArgs) { + if (explicitTypeArgs.length === typeParameters.length) { + inferredOrExplicitTypeArgs = explicitTypeArgs; } else { - if (triedToInferTypeArgs) { - continue; - } - - for (var j = 0; j < typeParameters.length; j++) { - typeReplacementMap[typeParameters[j].pullSymbolID] = this.semanticInfoChain.emptyTypeSymbol; - } - } - - if (couldNotAssignToConstraint) { + typeArgumentCountDiagnostic = typeArgumentCountDiagnostic || this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Signature_expected_0_type_arguments_got_1_instead, [typeParameters.length, explicitTypeArgs.length]); continue; } + } else { + TypeScript.Debug.assert(callEx.argumentList); + var typeArgumentInferenceContext = new TypeScript.InvocationTypeArgumentInferenceContext(this, context, signatures[i], callEx.argumentList.arguments); + inferredOrExplicitTypeArgs = this.inferArgumentTypesForSignature(typeArgumentInferenceContext, new TypeComparisonInfo(), context); + triedToInferTypeArgs = true; + } - specializedSignature = this.instantiateSignature(signatures[i], typeReplacementMap, true); + TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); - if (specializedSignature) { - resolvedSignatures[resolvedSignatures.length] = specializedSignature; + var mutableTypeReplacementMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(targetTypeReplacementMap ? targetTypeReplacementMap : []); + TypeScript.PullInstantiationHelpers.updateMutableTypeParameterArgumentMap(typeParameters, inferredOrExplicitTypeArgs, mutableTypeReplacementMap); + var typeReplacementMap = mutableTypeReplacementMap.typeParameterArgumentMap; + + if (explicitTypeArgs) { + for (var j = 0; j < typeParameters.length; j++) { + typeConstraint = typeParameters[j].getConstraint(); + + if (typeConstraint) { + if (typeConstraint.isGeneric()) { + typeConstraint = this.instantiateType(typeConstraint, typeReplacementMap); + } + + if (!this.sourceIsAssignableToTarget(inferredOrExplicitTypeArgs[j], typeConstraint, targetAST, context, null, true)) { + var enclosingSymbol = this.getEnclosingSymbolForAST(targetAST); + constraintDiagnostic = this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2, [inferredOrExplicitTypeArgs[j].toString(enclosingSymbol, true), typeConstraint.toString(enclosingSymbol, true), typeParameters[j].toString(enclosingSymbol, true)]); + couldNotAssignToConstraint = true; + } + + if (couldNotAssignToConstraint) { + break; + } + } } } + + if (couldNotAssignToConstraint) { + continue; + } + + specializedSignature = this.instantiateSignature(signatures[i], typeReplacementMap); + + if (specializedSignature) { + resolvedSignatures[resolvedSignatures.length] = specializedSignature; + } } else { if (!(callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { resolvedSignatures[resolvedSignatures.length] = signatures[i]; @@ -45643,7 +46916,7 @@ var TypeScript; this.resolveAST(callEx.argumentList.arguments, false, context); if (!couldNotFindGenericOverload) { - if (this.cachedFunctionInterfaceType() && this.sourceIsSubtypeOfTarget(targetTypeSymbol, this.cachedFunctionInterfaceType(), targetAST, context)) { + if (this.cachedFunctionInterfaceType() && this.sourceIsAssignableToTarget(targetTypeSymbol, this.cachedFunctionInterfaceType(), targetAST, context)) { if (callEx.argumentList.typeArgumentList) { this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Non_generic_functions_may_not_accept_type_arguments), additionalResults, context); } @@ -45662,7 +46935,7 @@ var TypeScript; return this.getNewErrorTypeSymbol(); } - var signature = this.resolveOverloads(callEx, signatures, callEx.argumentList.typeArgumentList != null, context, diagnostics); + var signature = this.resolveOverloads(callEx, signatures, callEx.argumentList.typeArgumentList !== null, context, diagnostics); var useBeforeResolutionSignatures = signature == null; if (!signature) { @@ -45681,10 +46954,11 @@ var TypeScript; signature = signatures[0]; } - if (!signature.isGeneric() && callEx.argumentList.typeArgumentList) { + var rootSignature = signature.getRootSymbol(); + if (!rootSignature.isGeneric() && callEx.argumentList.typeArgumentList) { this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Non_generic_functions_may_not_accept_type_arguments), additionalResults, context); - } else if (signature.isGeneric() && callEx.argumentList.typeArgumentList && signature.getTypeParameters() && (callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount() != signature.getTypeParameters().length)) { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Signature_expected_0_type_arguments_got_1_instead, [signature.getTypeParameters().length, callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()]), additionalResults, context); + } else if (rootSignature.isGeneric() && callEx.argumentList.typeArgumentList && rootSignature.getTypeParameters() && (callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount() !== rootSignature.getTypeParameters().length)) { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Signature_expected_0_type_arguments_got_1_instead, [rootSignature.getTypeParameters().length, callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()]), additionalResults, context); } var returnType = isSuperCall ? this.semanticInfoChain.voidTypeSymbol : signature.returnType; @@ -45710,14 +46984,14 @@ var TypeScript; } if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); + context.pushNewContextualType(contextualType); actualParametersContextTypeSymbols[i] = contextualType; } - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType != null, context); + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); if (contextualType) { - context.popContextualType(); + context.popAnyContextualType(); contextualType = null; } } @@ -45763,7 +47037,7 @@ var TypeScript; } var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (additionalResults && (callResolutionData != additionalResults)) { + if (additionalResults && (callResolutionData !== additionalResults)) { additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; additionalResults.candidateSignature = callResolutionData.candidateSignature; additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; @@ -45785,13 +47059,13 @@ var TypeScript; for (var i = 0; i < len; i++) { var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); + context.pushNewContextualType(contextualType); } - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType != null, context); + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); if (contextualType) { - context.popContextualType(); + context.popAnyContextualType(); contextualType = null; } } @@ -45810,6 +47084,7 @@ var TypeScript; }; PullTypeResolver.prototype.computeObjectCreationExpressionSymbol = function (callEx, context, additionalResults) { + var _this = this; var returnType = null; var targetSymbol = this.resolveAST(callEx.expression, false, context); @@ -45819,8 +47094,7 @@ var TypeScript; var constructSignatures = targetTypeSymbol.getConstructSignatures(); - var typeArgs = null; - var typeReplacementMap = null; + var explicitTypeArgs = null; var usedCallSignaturesInstead = false; var couldNotAssignToConstraint; var constraintDiagnostic = null; @@ -45846,18 +47120,18 @@ var TypeScript; if (constructSignatures.length) { if (callEx.argumentList && callEx.argumentList.typeArgumentList) { - typeArgs = []; + explicitTypeArgs = []; if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - typeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); } } } if (targetTypeSymbol.isGeneric()) { var resolvedSignatures = []; - var inferredTypeArgs; + var inferredOrExplicitTypeArgs; var specializedSignature; var typeParameters; var typeConstraint = null; @@ -45870,85 +47144,59 @@ var TypeScript; if (constructSignatures[i].isGeneric()) { typeParameters = constructSignatures[i].getTypeParameters(); - if (typeArgs) { - if (typeArgs.length == typeParameters.length) { - inferredTypeArgs = typeArgs; + if (explicitTypeArgs) { + if (explicitTypeArgs.length === typeParameters.length) { + inferredOrExplicitTypeArgs = explicitTypeArgs; } else { - typeArgumentCountDiagnostic = typeArgumentCountDiagnostic || this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Signature_expected_0_type_arguments_got_1_instead, [typeParameters.length, typeArgs.length]); + typeArgumentCountDiagnostic = typeArgumentCountDiagnostic || this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Signature_expected_0_type_arguments_got_1_instead, [typeParameters.length, explicitTypeArgs.length]); continue; } - } else if (!typeArgs && callEx.argumentList && callEx.argumentList.arguments && callEx.argumentList.arguments.nonSeparatorCount()) { - inferredTypeArgs = this.inferArgumentTypesForSignature(constructSignatures[i], new TypeScript.ArgumentInferenceContext(this, callEx.argumentList.arguments), new TypeComparisonInfo(), context); + } else if (callEx.argumentList) { + var typeArgumentInferenceContext = new TypeScript.InvocationTypeArgumentInferenceContext(this, context, constructSignatures[i], callEx.argumentList.arguments); + inferredOrExplicitTypeArgs = this.inferArgumentTypesForSignature(typeArgumentInferenceContext, new TypeComparisonInfo(), context); triedToInferTypeArgs = true; } else { - inferredTypeArgs = []; + inferredOrExplicitTypeArgs = TypeScript.ArrayUtilities.select(typeParameters, function (typeParameter) { + return typeParameter.getDefaultConstraint(_this.semanticInfoChain); + }); } - if (inferredTypeArgs) { - typeReplacementMap = []; + TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); - if (inferredTypeArgs.length) { - if (inferredTypeArgs.length < typeParameters.length) { - continue; - } + var mutableTypeReplacementMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(targetTypeReplacementMap ? targetTypeReplacementMap : []); + TypeScript.PullInstantiationHelpers.updateMutableTypeParameterArgumentMap(typeParameters, inferredOrExplicitTypeArgs, mutableTypeReplacementMap); + var typeReplacementMap = mutableTypeReplacementMap.typeParameterArgumentMap; - if (targetTypeReplacementMap) { - for (var symbolID in targetTypeReplacementMap) { - if (targetTypeReplacementMap.hasOwnProperty(symbolID)) { - typeReplacementMap[symbolID] = targetTypeReplacementMap[symbolID]; - } + if (explicitTypeArgs) { + for (var j = 0; j < typeParameters.length; j++) { + typeConstraint = typeParameters[j].getConstraint(); + + if (typeConstraint) { + if (typeConstraint.isGeneric()) { + typeConstraint = this.instantiateType(typeConstraint, typeReplacementMap); } - } - for (var j = 0; j < typeParameters.length; j++) { - typeReplacementMap[typeParameters[j].pullSymbolID] = inferredTypeArgs[j]; - } - for (var j = 0; j < typeParameters.length; j++) { - typeConstraint = typeParameters[j].getConstraint(); - - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var k = 0; k < typeParameters.length && k < inferredTypeArgs.length; k++) { - if (typeParameters[k] == typeConstraint) { - typeConstraint = inferredTypeArgs[k]; - } else { - typeConstraint = this.instantiateType(typeConstraint, typeReplacementMap); - } - } - } else if (typeConstraint.isGeneric()) { - typeConstraint = this.instantiateType(typeConstraint, typeReplacementMap); - } - - if (!this.sourceIsAssignableToTarget(inferredTypeArgs[j], typeConstraint, targetAST, context, null, true)) { - var enclosingSymbol = this.getEnclosingSymbolForAST(targetAST); - constraintDiagnostic = this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2, [inferredTypeArgs[j].toString(enclosingSymbol, true), typeConstraint.toString(enclosingSymbol, true), typeParameters[j].toString(enclosingSymbol, true)]); - couldNotAssignToConstraint = true; - } - - if (couldNotAssignToConstraint) { - break; - } + if (!this.sourceIsAssignableToTarget(inferredOrExplicitTypeArgs[j], typeConstraint, targetAST, context, null, true)) { + var enclosingSymbol = this.getEnclosingSymbolForAST(targetAST); + constraintDiagnostic = this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2, [inferredOrExplicitTypeArgs[j].toString(enclosingSymbol, true), typeConstraint.toString(enclosingSymbol, true), typeParameters[j].toString(enclosingSymbol, true)]); + couldNotAssignToConstraint = true; } - } - } else { - if (triedToInferTypeArgs) { - continue; - } else { - for (var j = 0; j < typeParameters.length; j++) { - typeReplacementMap[typeParameters[j].pullSymbolID] = this.semanticInfoChain.emptyTypeSymbol; + + if (couldNotAssignToConstraint) { + break; } } } + } - if (couldNotAssignToConstraint) { - continue; - } + if (couldNotAssignToConstraint) { + continue; + } - specializedSignature = this.instantiateSignature(constructSignatures[i], typeReplacementMap, true); + specializedSignature = this.instantiateSignature(constructSignatures[i], typeReplacementMap); - if (specializedSignature) { - resolvedSignatures[resolvedSignatures.length] = specializedSignature; - } + if (specializedSignature) { + resolvedSignatures[resolvedSignatures.length] = specializedSignature; } } else { if (!(callEx.argumentList && callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { @@ -45960,7 +47208,7 @@ var TypeScript; constructSignatures = resolvedSignatures; } - var signature = this.resolveOverloads(callEx, constructSignatures, callEx.argumentList && callEx.argumentList.typeArgumentList != null, context, diagnostics); + var signature = this.resolveOverloads(callEx, constructSignatures, callEx.argumentList && callEx.argumentList.typeArgumentList !== null, context, diagnostics); additionalResults.targetSymbol = targetSymbol; additionalResults.resolvedSignatures = constructSignatures; @@ -45998,15 +47246,15 @@ var TypeScript; returnType = signature.returnType; if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { - if (typeArgs && typeArgs.length) { - returnType = this.createInstantiatedType(returnType, typeArgs); + if (explicitTypeArgs && explicitTypeArgs.length) { + returnType = this.createInstantiatedType(returnType, explicitTypeArgs); } else { returnType = this.instantiateTypeToAny(returnType, context); } } if (usedCallSignaturesInstead) { - if (returnType != this.semanticInfoChain.voidTypeSymbol) { + if (returnType !== this.semanticInfoChain.voidTypeSymbol) { this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Call_signatures_used_in_a_new_expression_must_have_a_void_return_type), additionalResults, context); return this.getNewErrorTypeSymbol(); @@ -46044,14 +47292,14 @@ var TypeScript; } if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); + context.pushNewContextualType(contextualType); actualParametersContextTypeSymbols[i] = contextualType; } - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType != null, context); + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); if (contextualType) { - context.popContextualType(); + context.popAnyContextualType(); contextualType = null; } } @@ -46080,23 +47328,18 @@ var TypeScript; return this.getNewErrorTypeSymbol(); }; - PullTypeResolver.prototype.instantiateSignatureInContext = function (signatureA, signatureB, context) { + PullTypeResolver.prototype.instantiateSignatureInContext = function (signatureAToInstantiate, contextualSignatureB, context, shouldFixContextualSignatureParameterTypes) { var typeReplacementMap = []; var inferredTypeArgs; var specializedSignature; - var typeParameters = signatureA.getTypeParameters(); + var typeParameters = signatureAToInstantiate.getTypeParameters(); var typeConstraint = null; - var fixedParameterTypes = []; + var typeArgumentInferenceContext = new TypeScript.ContextualSignatureInstantiationTypeArgumentInferenceContext(this, context, signatureAToInstantiate, contextualSignatureB, shouldFixContextualSignatureParameterTypes); + inferredTypeArgs = this.inferArgumentTypesForSignature(typeArgumentInferenceContext, new TypeComparisonInfo(), context); - for (var i = 0; i < signatureB.parameters.length; i++) { - fixedParameterTypes.push(signatureB.parameters[i].isVarArg ? signatureB.parameters[i].type.getElementType() : signatureB.parameters[i].type); - } - - inferredTypeArgs = this.inferArgumentTypesForSignature(signatureA, new TypeScript.ArgumentInferenceContext(this, fixedParameterTypes), new TypeComparisonInfo(), context); - - var functionTypeA = signatureA.functionType; - var functionTypeB = signatureB.functionType; + var functionTypeA = signatureAToInstantiate.functionType; + var functionTypeB = contextualSignatureB.functionType; var enclosingTypeParameterMap; if (functionTypeA) { @@ -46115,34 +47358,9 @@ var TypeScript; } } - for (var i = 0; i < typeParameters.length; i++) { - typeReplacementMap[typeParameters[i].pullSymbolID] = inferredTypeArgs[i]; - } - for (var i = 0; i < typeParameters.length; i++) { - typeConstraint = typeParameters[i].getConstraint(); + TypeScript.PullInstantiationHelpers.updateTypeParameterArgumentMap(typeParameters, inferredTypeArgs, typeReplacementMap); - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var j = 0; j < typeParameters.length && j < inferredTypeArgs.length; j++) { - if (typeParameters[j] == typeConstraint) { - typeConstraint = inferredTypeArgs[j]; - } - } - } else if (typeConstraint.isGeneric()) { - typeConstraint = TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, typeConstraint, typeReplacementMap); - } - - if (!this.sourceIsAssignableToTarget(inferredTypeArgs[i], typeConstraint, null, context, null, true)) { - if (this.signaturesAreIdentical(signatureA, signatureB, true)) { - return signatureA; - } else { - return null; - } - } - } - } - - return this.instantiateSignature(signatureA, typeReplacementMap, true); + return this.instantiateSignature(signatureAToInstantiate, typeReplacementMap); }; PullTypeResolver.prototype.resolveCastExpression = function (assertionExpression, context) { @@ -46158,16 +47376,21 @@ var TypeScript; PullTypeResolver.prototype.typeCheckCastExpression = function (assertionExpression, context, typeAssertionType) { this.setTypeChecked(assertionExpression, context); - context.pushContextualType(typeAssertionType, context.inProvisionalResolution(), null); + context.pushNewContextualType(typeAssertionType); var exprType = this.resolveAST(assertionExpression.expression, true, context).type; - context.popContextualType(); + context.popAnyContextualType(); this.resolveDeclaredSymbol(typeAssertionType, context); this.resolveDeclaredSymbol(exprType, context); var comparisonInfo = new TypeComparisonInfo(); - var isAssignable = this.sourceIsAssignableToTarget(typeAssertionType, exprType, assertionExpression, context, comparisonInfo) || this.sourceIsAssignableToTarget(exprType, typeAssertionType, assertionExpression, context, comparisonInfo); + var isAssignable = this.sourceIsAssignableToTarget(exprType, typeAssertionType, assertionExpression, context, comparisonInfo); + + if (!isAssignable) { + var widenedExprType = exprType.widenedType(this, assertionExpression.expression, context); + isAssignable = this.sourceIsAssignableToTarget(typeAssertionType, widenedExprType, assertionExpression, context, comparisonInfo); + } if (!isAssignable) { var enclosingSymbol = this.getEnclosingSymbolForAST(assertionExpression); @@ -46183,9 +47406,9 @@ var TypeScript; var leftExpr = this.resolveAST(binaryExpression.left, false, context); var leftType = leftExpr.type; - context.pushContextualType(leftType, context.inProvisionalResolution(), null); + context.pushNewContextualType(leftType); var rightType = this.resolveAST(binaryExpression.right, true, context).type; - context.popContextualType(); + context.popAnyContextualType(); rightType = this.getInstanceTypeForAssignment(binaryExpression.left, rightType, context); @@ -46228,30 +47451,82 @@ var TypeScript; } if (type.isArrayNamedTypeReference()) { - var elementType = this.widenType(type.getElementType(), null, context); - - if (this.compilationSettings.noImplicitAny() && ast && ast.kind() === 214 /* ArrayLiteralExpression */) { - if (elementType === this.semanticInfoChain.anyTypeSymbol && type.getElementType() !== this.semanticInfoChain.anyTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Array_Literal_implicitly_has_an_any_type_from_widening)); - } - } - - var arraySymbol = elementType.getArrayType(); - - if (!arraySymbol) { - arraySymbol = this.createInstantiatedType(this.cachedArrayInterfaceType(), [elementType]); - - if (!arraySymbol) { - arraySymbol = this.semanticInfoChain.anyTypeSymbol; - } - } - - return arraySymbol; + return this.widenArrayType(type, ast, context); + } else if (type.kind === 256 /* ObjectLiteral */) { + return this.widenObjectLiteralType(type, ast, context); } return type; }; + PullTypeResolver.prototype.widenArrayType = function (type, ast, context) { + var elementType = type.getElementType().widenedType(this, ast, context); + + if (this.compilationSettings.noImplicitAny() && ast) { + if (elementType === this.semanticInfoChain.anyTypeSymbol && type.getElementType() !== this.semanticInfoChain.anyTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Array_Literal_implicitly_has_an_any_type_from_widening)); + } + } + + return this.getArrayType(elementType); + }; + + PullTypeResolver.prototype.widenObjectLiteralType = function (type, ast, context) { + if (!this.needsToWidenObjectLiteralType(type, ast, context)) { + return type; + } + + TypeScript.Debug.assert(type.name === ""); + var newObjectTypeSymbol = new TypeScript.PullTypeSymbol(type.name, type.kind); + var declsOfObjectType = type.getDeclarations(); + TypeScript.Debug.assert(declsOfObjectType.length === 1); + newObjectTypeSymbol.addDeclaration(declsOfObjectType[0]); + var members = type.getMembers(); + + for (var i = 0; i < members.length; i++) { + var memberType = members[i].type; + + var widenedMemberType = members[i].type.widenedType(this, ast, context); + var newMember = new TypeScript.PullSymbol(members[i].name, members[i].kind); + + var declsOfMember = members[i].getDeclarations(); + + newMember.addDeclaration(declsOfMember[0]); + newMember.type = widenedMemberType; + newObjectTypeSymbol.addMember(newMember); + newMember.setResolved(); + + if (this.compilationSettings.noImplicitAny() && ast && widenedMemberType === this.semanticInfoChain.anyTypeSymbol && memberType !== this.semanticInfoChain.anyTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Object_literal_s_property_0_implicitly_has_an_any_type_from_widening, [members[i].name])); + } + } + + var indexers = type.getIndexSignatures(); + for (var i = 0; i < indexers.length; i++) { + var newIndexer = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + var parameter = indexers[i].parameters[0]; + var newParameter = new TypeScript.PullSymbol(parameter.name, parameter.kind); + newParameter.type = parameter.type; + newIndexer.addParameter(newParameter); + newIndexer.returnType = indexers[i].returnType; + newObjectTypeSymbol.addIndexSignature(newIndexer); + } + + return newObjectTypeSymbol; + }; + + PullTypeResolver.prototype.needsToWidenObjectLiteralType = function (type, ast, context) { + var members = type.getMembers(); + for (var i = 0; i < members.length; i++) { + var memberType = members[i].type; + if (memberType !== memberType.widenedType(this, ast, context)) { + return true; + } + } + + return false; + }; + PullTypeResolver.prototype.findBestCommonType = function (collection, context, comparisonInfo) { var len = collection.getLength(); @@ -46268,15 +47543,11 @@ var TypeScript; PullTypeResolver.prototype.typeIsBestCommonTypeCandidate = function (candidateType, collection, context) { for (var i = 0; i < collection.getLength(); i++) { var otherType = collection.getTypeAtIndex(i); - if (candidateType == otherType) { + if (candidateType === otherType) { continue; } - if (candidateType.isTypeParameter() && !otherType.isTypeParameter()) { - return false; - } else if (!candidateType.isTypeParameter() && otherType.isTypeParameter()) { - continue; - } else if (!this.sourceIsSubtypeOfTarget(otherType, candidateType, null, context)) { + if (!this.sourceIsSubtypeOfTarget(otherType, candidateType, null, context)) { return false; } } @@ -46284,7 +47555,7 @@ var TypeScript; return true; }; - PullTypeResolver.prototype.typesAreIdenticalInEnclosingTypes = function (t1, t2, t1EnclosingType, t2EnclosingType, val) { + PullTypeResolver.prototype.typesAreIdenticalInEnclosingTypes = function (t1, t2, context) { t1 = this.getSymbolForRelationshipCheck(t1); t2 = this.getSymbolForRelationshipCheck(t2); @@ -46293,17 +47564,22 @@ var TypeScript; } if (t1 && t2) { - var t1GenerativeTypeKind = t1EnclosingType ? t1.getGenerativeTypeClassification(t1EnclosingType) : 0 /* Unknown */; - var t2GenerativeTypeKind = t2EnclosingType ? t2.getGenerativeTypeClassification(t2EnclosingType) : 0 /* Unknown */; - if (t1GenerativeTypeKind == 3 /* InfinitelyExpanding */ || t2GenerativeTypeKind == 3 /* InfinitelyExpanding */) { - return this.infinitelyExpandingTypesAreIdentical(t1, t2); + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + return this.infinitelyExpandingTypesAreIdentical(t1, t2, context); } } - return this.typesAreIdentical(t1, t2, val); + return this.typesAreIdentical(t1, t2, context); }; - PullTypeResolver.prototype.typesAreIdentical = function (t1, t2, val) { + PullTypeResolver.prototype.typesAreIdenticalWithNewEnclosingTypes = function (t1, t2, context) { + var enclosingTypeWalkers = context.resetEnclosingTypeWalkers(); + var areTypesIdentical = this.typesAreIdentical(t1, t2, context); + context.setEnclosingTypeWalkers(enclosingTypeWalkers); + return areTypesIdentical; + }; + + PullTypeResolver.prototype.typesAreIdentical = function (t1, t2, context) { t1 = this.getSymbolForRelationshipCheck(t1); t2 = this.getSymbolForRelationshipCheck(t2); @@ -46315,12 +47591,8 @@ var TypeScript; return false; } - if (val && t1.isPrimitive() && t1.isStringConstant() && t2 === this.semanticInfoChain.stringTypeSymbol) { - return (val.kind() === 14 /* StringLiteral */) && (TypeScript.stripStartAndEndQuotes(val.text()) === TypeScript.stripStartAndEndQuotes(t1.name)); - } - - if (val && t2.isPrimitive() && t2.isStringConstant() && t2 === this.semanticInfoChain.stringTypeSymbol) { - return (val.kind() === 14 /* StringLiteral */) && (TypeScript.stripStartAndEndQuotes(val.text()) === TypeScript.stripStartAndEndQuotes(t2.name)); + if (TypeScript.hasFlag(t1.kind, 64 /* Enum */) || TypeScript.hasFlag(t2.kind, 64 /* Enum */)) { + return false; } if (t1.isPrimitive() && t1.isStringConstant() && t2.isPrimitive() && t2.isStringConstant()) { @@ -46335,7 +47607,12 @@ var TypeScript; return true; } - if (t1.isTypeParameter() != t2.isTypeParameter()) { + var isIdentical = this.identicalCache.valueAt(t1.pullSymbolID, t2.pullSymbolID); + if (isIdentical != undefined) { + return isIdentical; + } + + if (t1.isTypeParameter() !== t2.isTypeParameter()) { return false; } else if (t1.isTypeParameter()) { var t1ParentDeclaration = t1.getDeclarations()[0].getParentDecl(); @@ -46348,27 +47625,42 @@ var TypeScript; } } - var isIdentical = this.identicalCache.valueAt(t1.pullSymbolID, t2.pullSymbolID); - if (isIdentical != undefined) { - return isIdentical; - } - - if ((t1.kind & 64 /* Enum */) || (t2.kind & 64 /* Enum */)) { - return t1.getAssociatedContainerType() === t2 || t2.getAssociatedContainerType() === t1; - } - - if (t1.isPrimitive() != t2.isPrimitive()) { + if (t1.isPrimitive() !== t2.isPrimitive()) { return false; } - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, false); + this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, true); + var symbolsWhenStartedWalkingTypes = context.startWalkingTypes(t1, t2); + isIdentical = this.typesAreIdenticalWorker(t1, t2, context); + context.endWalkingTypes(symbolsWhenStartedWalkingTypes); + this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, isIdentical); + + return isIdentical; + }; + + PullTypeResolver.prototype.typesAreIdenticalWorker = function (t1, t2, context) { + if (t1.getIsSpecialized() && t2.getIsSpecialized()) { + if (TypeScript.PullHelpers.getRootType(t1) === TypeScript.PullHelpers.getRootType(t2) && TypeScript.PullHelpers.getRootType(t1).isNamedTypeSymbol()) { + var t1TypeArguments = t1.getTypeArguments(); + var t2TypeArguments = t2.getTypeArguments(); + + if (t1TypeArguments && t2TypeArguments) { + for (var i = 0; i < t1TypeArguments.length; i++) { + if (!this.typesAreIdenticalWithNewEnclosingTypes(t1TypeArguments[i], t2TypeArguments[i], context)) { + return false; + } + } + } + + return true; + } + } if (t1.hasMembers() && t2.hasMembers()) { var t1Members = t1.getAllMembers(68147712 /* SomeValue */, 0 /* all */); var t2Members = t2.getAllMembers(68147712 /* SomeValue */, 0 /* all */); - if (t1Members.length != t2Members.length) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); + if (t1Members.length !== t2Members.length) { return false; } @@ -46380,22 +47672,13 @@ var TypeScript; for (var iMember = 0; iMember < t1Members.length; iMember++) { t1MemberSymbol = t1Members[iMember]; - t2MemberSymbol = this.getMemberSymbol(t1MemberSymbol.name, 68147712 /* SomeValue */, t2); + t2MemberSymbol = this.getNamedPropertySymbol(t1MemberSymbol.name, 68147712 /* SomeValue */, t2); - if (!t2MemberSymbol || (t1MemberSymbol.isOptional != t2MemberSymbol.isOptional)) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); - return false; - } - - t1MemberType = t1MemberSymbol.type; - t2MemberType = t2MemberSymbol.type; - - if (!this.typesAreIdenticalInEnclosingTypes(t1MemberType, t2MemberType, t1, t2)) { + if (!this.propertiesAreIdentical(t1MemberSymbol, t2MemberSymbol, context)) { return false; } } } else if (t1.hasMembers() || t2.hasMembers()) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); return false; } @@ -46408,26 +47691,57 @@ var TypeScript; var t1IndexSigs = t1.getIndexSignatures(); var t2IndexSigs = t2.getIndexSignatures(); - if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs)) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); + if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs, context)) { return false; } - if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs)) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); + if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs, context)) { return false; } - if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs)) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); + if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs, context)) { return false; } - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, true); return true; }; - PullTypeResolver.prototype.signatureGroupsAreIdentical = function (sg1, sg2) { + PullTypeResolver.prototype.propertiesAreIdentical = function (propertySymbol1, propertySymbol2, context) { + if (!propertySymbol2 || (propertySymbol1.isOptional !== propertySymbol2.isOptional)) { + return false; + } + + var t1MemberSymbolIsPrivate = propertySymbol1.anyDeclHasFlag(2 /* Private */); + var t2MemberSymbolIsPrivate = propertySymbol2.anyDeclHasFlag(2 /* Private */); + + if (t1MemberSymbolIsPrivate !== t2MemberSymbolIsPrivate) { + return false; + } else if (t2MemberSymbolIsPrivate && t1MemberSymbolIsPrivate) { + var t1MemberSymbolDecl = propertySymbol1.getDeclarations()[0]; + var sourceDecl = propertySymbol2.getDeclarations()[0]; + if (t1MemberSymbolDecl !== sourceDecl) { + return false; + } + } + + var t1MemberType = propertySymbol1.type; + var t2MemberType = propertySymbol2.type; + + context.walkMemberTypes(propertySymbol1.name); + var areMemberTypesIdentical = this.typesAreIdenticalInEnclosingTypes(t1MemberType, t2MemberType, context); + context.postWalkMemberTypes(); + return areMemberTypesIdentical; + }; + + PullTypeResolver.prototype.propertiesAreIdenticalWithNewEnclosingTypes = function (type1, type2, property1, property2, context) { + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(type1, type2); + var arePropertiesIdentical = this.propertiesAreIdentical(property1, property2, context); + context.setEnclosingTypeWalkers(enclosingWalkers); + return arePropertiesIdentical; + }; + + PullTypeResolver.prototype.signatureGroupsAreIdentical = function (sg1, sg2, context) { if (sg1 === sg2) { return true; } @@ -46436,75 +47750,15 @@ var TypeScript; return false; } - if (sg1.length != sg2.length) { + if (sg1.length !== sg2.length) { return false; } - var sig1 = null; - var sig2 = null; - var sigsMatch = false; - - for (var iSig1 = 0; iSig1 < sg1.length; iSig1++) { - sig1 = sg1[iSig1]; - - for (var iSig2 = 0; iSig2 < sg2.length; iSig2++) { - sig2 = sg2[iSig2]; - - if (this.signaturesAreIdentical(sig1, sig2)) { - sigsMatch = true; - break; - } - } - - if (sigsMatch) { - sigsMatch = false; - continue; - } - - return false; - } - - return true; - }; - - PullTypeResolver.prototype.signaturesAreIdentical = function (s1, s2, includingReturnType) { - if (typeof includingReturnType === "undefined") { includingReturnType = true; } - if (s1 === s2) { - return true; - } - - if (s1.hasVarArgs != s2.hasVarArgs) { - return false; - } - - if (s1.nonOptionalParamCount != s2.nonOptionalParamCount) { - return false; - } - - if (!!(s1.typeParameters && s1.typeParameters.length) != !!(s2.typeParameters && s2.typeParameters.length)) { - return false; - } - - if (s1.typeParameters && s2.typeParameters && (s1.typeParameters.length != s2.typeParameters.length)) { - return false; - } - - if (s1.parameters.length != s2.parameters.length) { - return false; - } - - this.resolveDeclaredSymbol(s1); - this.resolveDeclaredSymbol(s2); - - var s1Params = s1.parameters; - var s2Params = s2.parameters; - - if (includingReturnType && !this.typesAreIdenticalInEnclosingTypes(s1.returnType, s2.returnType, s1.functionType, s2.functionType)) { - return false; - } - - for (var iParam = 0; iParam < s1Params.length; iParam++) { - if (!this.typesAreIdenticalInEnclosingTypes(s1Params[iParam].type, s2Params[iParam].type, s1.functionType, s2.functionType)) { + for (var i = 0; i < sg1.length; i++) { + context.walkSignatures(sg1[i].kind, i); + var areSignaturesIdentical = this.signaturesAreIdentical(sg1[i], sg2[i], context, true); + context.postWalkSignatures(); + if (!areSignaturesIdentical) { return false; } } @@ -46512,18 +47766,152 @@ var TypeScript; return true; }; - PullTypeResolver.prototype.substituteUpperBoundForType = function (type) { - if (!type || !type.isTypeParameter()) { - return type; + PullTypeResolver.prototype.typeParametersAreIdentical = function (tp1, tp2, context) { + var typeParamsAreIdentical = this.typeParametersAreIdenticalWorker(tp1, tp2, context); + + this.setTypeParameterIdentity(tp1, tp2, undefined); + + return typeParamsAreIdentical; + }; + + PullTypeResolver.prototype.typeParametersAreIdenticalWorker = function (tp1, tp2, context) { + if (!!(tp1 && tp1.length) !== !!(tp2 && tp2.length)) { + return false; } - var constraint = type.getConstraint(); - - if (constraint && (constraint != type)) { - return this.substituteUpperBoundForType(constraint); + if (tp1 && tp2 && (tp1.length !== tp2.length)) { + return false; } - return type; + if (tp1 && tp2) { + for (var i = 0; i < tp1.length; i++) { + context.walkTypeParameterConstraints(i); + var areConstraintsIdentical = this.typesAreIdentical(tp1[i].getConstraint(), tp2[i].getConstraint(), context); + context.postWalkTypeParameterConstraints(); + if (!areConstraintsIdentical) { + return false; + } + } + } + + return true; + }; + + PullTypeResolver.prototype.setTypeParameterIdentity = function (tp1, tp2, val) { + if (tp1 && tp2 && tp1.length === tp2.length) { + for (var i = 0; i < tp1.length; i++) { + this.identicalCache.setValueAt(tp1[i].pullSymbolID, tp2[i].pullSymbolID, val); + } + } + }; + + PullTypeResolver.prototype.signaturesAreIdenticalWithNewEnclosingTypes = function (s1, s2, context, includingReturnType) { + if (typeof includingReturnType === "undefined") { includingReturnType = true; } + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(s1, s2); + var areSignaturesIdentical = this.signaturesAreIdentical(s1, s2, context, includingReturnType); + context.setEnclosingTypeWalkers(enclosingWalkers); + return areSignaturesIdentical; + }; + + PullTypeResolver.prototype.signaturesAreIdentical = function (s1, s2, context, includingReturnType) { + if (typeof includingReturnType === "undefined") { includingReturnType = true; } + if (s1 === s2) { + return true; + } + + var signaturesIdentical = this.identicalCache.valueAt(s1.pullSymbolID, s2.pullSymbolID); + if (signaturesIdentical || (signaturesIdentical != undefined && includingReturnType)) { + return signaturesIdentical; + } + + var oldValue = signaturesIdentical; + this.identicalCache.setValueAt(s1.pullSymbolID, s2.pullSymbolID, true); + + signaturesIdentical = this.signaturesAreIdenticalWorker(s1, s2, context, includingReturnType); + + if (includingReturnType) { + this.identicalCache.setValueAt(s1.pullSymbolID, s2.pullSymbolID, signaturesIdentical); + } else { + this.identicalCache.setValueAt(s1.pullSymbolID, s2.pullSymbolID, oldValue); + } + + return signaturesIdentical; + }; + + PullTypeResolver.prototype.signaturesAreIdenticalWorker = function (s1, s2, context, includingReturnType) { + if (typeof includingReturnType === "undefined") { includingReturnType = true; } + if (s1.hasVarArgs !== s2.hasVarArgs) { + return false; + } + + if (s1.nonOptionalParamCount !== s2.nonOptionalParamCount) { + return false; + } + + if (s1.parameters.length !== s2.parameters.length) { + return false; + } + + var s1TypeParameters = s1.getTypeParameters(); + var s2TypeParameters = s2.getTypeParameters(); + this.setTypeParameterIdentity(s1TypeParameters, s2TypeParameters, true); + + var typeParametersParametersAndReturnTypesAreIdentical = this.signatureTypeParametersParametersAndReturnTypesAreIdentical(s1, s2, context, includingReturnType); + + this.setTypeParameterIdentity(s1TypeParameters, s2TypeParameters, undefined); + return typeParametersParametersAndReturnTypesAreIdentical; + }; + + PullTypeResolver.prototype.signatureTypeParametersParametersAndReturnTypesAreIdentical = function (s1, s2, context, includingReturnType) { + if (!this.typeParametersAreIdenticalWorker(s1.getTypeParameters(), s2.getTypeParameters(), context)) { + return false; + } + + if (includingReturnType) { + TypeScript.PullHelpers.resolveDeclaredSymbolToUseType(s1); + TypeScript.PullHelpers.resolveDeclaredSymbolToUseType(s2); + context.walkReturnTypes(); + var areReturnTypesIdentical = this.typesAreIdenticalInEnclosingTypes(s1.returnType, s2.returnType, context); + context.postWalkReturnTypes(); + if (!areReturnTypesIdentical) { + return false; + } + } + + var s1Params = s1.parameters; + var s2Params = s2.parameters; + + for (var iParam = 0; iParam < s1Params.length; iParam++) { + TypeScript.PullHelpers.resolveDeclaredSymbolToUseType(s1Params[iParam]); + TypeScript.PullHelpers.resolveDeclaredSymbolToUseType(s2Params[iParam]); + context.walkParameterTypes(iParam); + var areParameterTypesIdentical = this.typesAreIdenticalInEnclosingTypes(s1Params[iParam].type, s2Params[iParam].type, context); + context.postWalkParameterTypes(); + + if (!areParameterTypesIdentical) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.signatureReturnTypesAreIdentical = function (s1, s2, context) { + var s1TypeParameters = s1.getTypeParameters(); + var s2TypeParameters = s2.getTypeParameters(); + this.setTypeParameterIdentity(s1TypeParameters, s2TypeParameters, true); + + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(s1, s2); + context.walkReturnTypes(); + var returnTypeIsIdentical = this.typesAreIdenticalInEnclosingTypes(s1.returnType, s2.returnType, context); + + context.setEnclosingTypeWalkers(enclosingWalkers); + + this.setTypeParameterIdentity(s1TypeParameters, s2TypeParameters, undefined); + + return returnTypeIsIdentical; }; PullTypeResolver.prototype.symbolsShareDeclaration = function (symbol1, symbol2) { @@ -46531,58 +47919,7 @@ var TypeScript; var decls2 = symbol2.getDeclarations(); if (decls1.length && decls2.length) { - return decls1[0].isEqual(decls2[0]); - } - - return false; - }; - - PullTypeResolver.prototype.sourceExtendsTarget = function (source, target, context) { - if (source.isGeneric() != target.isGeneric()) { - return false; - } - - if (source.isTypeReference() && target.isTypeReference()) { - if (source.referencedTypeSymbol.hasBase(target.referencedTypeSymbol)) { - var sourceTypeArguments = source.getTypeArguments(); - var targetTypeArguments = target.getTypeArguments(); - - if (!(sourceTypeArguments && targetTypeArguments) || sourceTypeArguments.length != targetTypeArguments.length) { - return false; - } - - for (var i = 0; i < targetTypeArguments.length; i++) { - if (!this.sourceExtendsTarget(sourceTypeArguments[i], targetTypeArguments[i], context)) { - return false; - } - } - - return true; - } - } - - if (source.hasBase(target)) { - return true; - } - - if (context.isInBaseTypeResolution() && (source.kind & (16 /* Interface */ | 8 /* Class */)) && (target.kind & (16 /* Interface */ | 8 /* Class */))) { - var sourceDecls = source.getDeclarations(); - var extendsSymbol = null; - - for (var i = 0; i < sourceDecls.length; i++) { - var sourceAST = this.semanticInfoChain.getASTForDecl(sourceDecls[i]); - var extendsClause = TypeScript.getExtendsHeritageClause(sourceAST.heritageClauses); - - if (extendsClause) { - for (var j = 0; j < extendsClause.typeNames.nonSeparatorCount(); j++) { - extendsSymbol = this.semanticInfoChain.getSymbolForAST(extendsClause.typeNames.nonSeparatorAt(j)); - - if (extendsSymbol && (extendsSymbol == target || this.sourceExtendsTarget(extendsSymbol, target, context))) { - return true; - } - } - } - } + return decls1[0] === decls2[0]; } return false; @@ -46592,44 +47929,68 @@ var TypeScript; return this.sourceIsRelatableToTarget(source, target, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); }; - PullTypeResolver.prototype.sourceMembersAreSubtypeOfTargetMembers = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceMembersAreRelatableToTargetMembers(source, target, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + PullTypeResolver.prototype.sourceMembersAreAssignableToTargetMembers = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(source, target); + var areSourceMembersAreAssignableToTargetMembers = this.sourceMembersAreRelatableToTargetMembers(source, target, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.setEnclosingTypeWalkers(enclosingWalkers); + return areSourceMembersAreAssignableToTargetMembers; }; - PullTypeResolver.prototype.sourcePropertyIsSubtypeOfTargetProperty = function (source, target, sourceProp, targetProp, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + PullTypeResolver.prototype.sourcePropertyIsAssignableToTargetProperty = function (source, target, sourceProp, targetProp, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(source, target); + var isSourcePropertyIsAssignableToTargetProperty = this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.setEnclosingTypeWalkers(enclosingWalkers); + return isSourcePropertyIsAssignableToTargetProperty; }; - PullTypeResolver.prototype.sourceCallSignaturesAreSubtypeOfTargetCallSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceCallSignaturesAreRelatableToTargetCallSignatures(source, target, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + PullTypeResolver.prototype.sourceCallSignaturesAreAssignableToTargetCallSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(source, target); + var areSourceCallSignaturesAssignableToTargetCallSignatures = this.sourceCallSignaturesAreRelatableToTargetCallSignatures(source, target, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.setEnclosingTypeWalkers(enclosingWalkers); + return areSourceCallSignaturesAssignableToTargetCallSignatures; }; - PullTypeResolver.prototype.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(source, target, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + PullTypeResolver.prototype.sourceConstructSignaturesAreAssignableToTargetConstructSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(source, target); + var areSourceConstructSignaturesAssignableToTargetConstructSignatures = this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(source, target, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.setEnclosingTypeWalkers(enclosingWalkers); + return areSourceConstructSignaturesAssignableToTargetConstructSignatures; }; - PullTypeResolver.prototype.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(source, target, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + PullTypeResolver.prototype.sourceIndexSignaturesAreAssignableToTargetIndexSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(source, target); + var areSourceIndexSignaturesAssignableToTargetIndexSignatures = this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(source, target, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.setEnclosingTypeWalkers(enclosingWalkers); + return areSourceIndexSignaturesAssignableToTargetIndexSignatures; }; - PullTypeResolver.prototype.typeIsSubtypeOfFunction = function (source, ast, context) { - if (source.getCallSignatures().length || source.getConstructSignatures().length) { + PullTypeResolver.prototype.typeIsAssignableToFunction = function (source, ast, context) { + if (source.isFunctionType()) { return true; } - return this.cachedFunctionInterfaceType() && this.sourceIsSubtypeOfTarget(source, this.cachedFunctionInterfaceType(), ast, context); + return this.cachedFunctionInterfaceType() && this.sourceIsAssignableToTarget(source, this.cachedFunctionInterfaceType(), ast, context); }; - PullTypeResolver.prototype.signatureIsSubtypeOfTarget = function (s1, s2, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.signatureIsRelatableToTarget(s1, s2, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + PullTypeResolver.prototype.signatureIsAssignableToTarget = function (s1, s2, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(s1, s2); + var isSignatureIsAssignableToTarget = this.signatureIsRelatableToTarget(s1, s2, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.setEnclosingTypeWalkers(enclosingWalkers); + return isSignatureIsAssignableToTarget; }; PullTypeResolver.prototype.sourceIsAssignableToTarget = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { return this.sourceIsRelatableToTarget(source, target, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); }; - PullTypeResolver.prototype.signatureIsAssignableToTarget = function (s1, s2, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.signatureIsRelatableToTarget(s1, s2, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + PullTypeResolver.prototype.sourceIsAssignableToTargetWithNewEnclosingTypes = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + return this.sourceIsRelatableToTargetWithNewEnclosingTypes(source, target, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); }; PullTypeResolver.prototype.getSymbolForRelationshipCheck = function (symbol) { @@ -46640,7 +48001,7 @@ var TypeScript; return symbol; }; - PullTypeResolver.prototype.sourceIsRelatableToTargetInEnclosingTypes = function (source, target, sourceEnclosingType, targetEnclosingType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + PullTypeResolver.prototype.sourceIsRelatableToTargetInEnclosingTypes = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { source = this.getSymbolForRelationshipCheck(source); target = this.getSymbolForRelationshipCheck(target); @@ -46649,9 +48010,7 @@ var TypeScript; } if (source && target) { - var sourceGenerativeTypeKind = sourceEnclosingType ? source.getGenerativeTypeClassification(sourceEnclosingType) : 0 /* Unknown */; - var targetGenerativeTypeKind = targetEnclosingType ? target.getGenerativeTypeClassification(targetEnclosingType) : 0 /* Unknown */; - if (sourceGenerativeTypeKind == 3 /* InfinitelyExpanding */ || targetGenerativeTypeKind == 3 /* InfinitelyExpanding */) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { return this.infinitelyExpandingSourceTypeIsRelatableToTargetType(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); } } @@ -46659,6 +48018,27 @@ var TypeScript; return this.sourceIsRelatableToTarget(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); }; + PullTypeResolver.prototype.sourceIsRelatableToTargetWithNewEnclosingTypes = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + var isSourceRelatable = this.sourceIsRelatableToTarget(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.setEnclosingTypeWalkers(enclosingWalkers); + return isSourceRelatable; + }; + + PullTypeResolver.prototype.sourceIsRelatableToTargetInCache = function (source, target, comparisonCache, comparisonInfo) { + var isRelatable = comparisonCache.valueAt(source.pullSymbolID, target.pullSymbolID); + + if (isRelatable) { + return { isRelatable: isRelatable }; + } + + if (isRelatable != undefined && !comparisonInfo) { + return { isRelatable: isRelatable }; + } + + return null; + }; + PullTypeResolver.prototype.sourceIsRelatableToTarget = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { source = this.getSymbolForRelationshipCheck(source); target = this.getSymbolForRelationshipCheck(target); @@ -46671,25 +48051,11 @@ var TypeScript; return true; } - var sourceSubstitution = source; + var sourceApparentType = this.getApparentType(source); - if (source == this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { - this.resolveDeclaredSymbol(this.cachedStringInterfaceType(), context); - sourceSubstitution = this.cachedStringInterfaceType(); - } else if (source == this.semanticInfoChain.numberTypeSymbol && this.cachedNumberInterfaceType()) { - this.resolveDeclaredSymbol(this.cachedNumberInterfaceType(), context); - sourceSubstitution = this.cachedNumberInterfaceType(); - } else if (source == this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { - this.resolveDeclaredSymbol(this.cachedBooleanInterfaceType(), context); - sourceSubstitution = this.cachedBooleanInterfaceType(); - } else if (TypeScript.PullHelpers.symbolIsEnum(source) && this.cachedNumberInterfaceType()) { - sourceSubstitution = this.cachedNumberInterfaceType(); - } else if (source.isTypeParameter()) { - sourceSubstitution = this.substituteUpperBoundForType(source); - } - - if (comparisonCache.valueAt(source.pullSymbolID, target.pullSymbolID) != undefined) { - return true; + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(source, target, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; } if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && target.isStringConstant()) { @@ -46704,10 +48070,10 @@ var TypeScript; if (this.isAnyOrEquivalent(target)) { return true; } + } - if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && source.isStringConstant()) { - return true; - } + if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && source.isStringConstant()) { + return true; } if (source.isPrimitive() && source.isStringConstant() && target.isPrimitive() && target.isStringConstant()) { @@ -46718,18 +48084,18 @@ var TypeScript; return true; } - if ((source === this.semanticInfoChain.nullTypeSymbol) && (target != this.semanticInfoChain.undefinedTypeSymbol && target != this.semanticInfoChain.voidTypeSymbol)) { + if ((source === this.semanticInfoChain.nullTypeSymbol) && (target !== this.semanticInfoChain.undefinedTypeSymbol && target != this.semanticInfoChain.voidTypeSymbol)) { return true; } - if (target == this.semanticInfoChain.voidTypeSymbol) { - if (source == this.semanticInfoChain.undefinedTypeSymbol || source == this.semanticInfoChain.nullTypeSymbol) { + if (target === this.semanticInfoChain.voidTypeSymbol) { + if (source === this.semanticInfoChain.undefinedTypeSymbol || source == this.semanticInfoChain.nullTypeSymbol) { return true; } return false; - } else if (source == this.semanticInfoChain.voidTypeSymbol) { - if (target == this.semanticInfoChain.anyTypeSymbol) { + } else if (source === this.semanticInfoChain.voidTypeSymbol) { + if (target === this.semanticInfoChain.anyTypeSymbol) { return true; } @@ -46753,21 +48119,20 @@ var TypeScript; } if (source.getIsSpecialized() && target.getIsSpecialized()) { - if (TypeScript.PullHelpers.getRootType(source) == TypeScript.PullHelpers.getRootType(target)) { + if (TypeScript.PullHelpers.getRootType(source) === TypeScript.PullHelpers.getRootType(target) && TypeScript.PullHelpers.getRootType(source).isNamedTypeSymbol()) { var sourceTypeArguments = source.getTypeArguments(); var targetTypeArguments = target.getTypeArguments(); if (sourceTypeArguments && targetTypeArguments) { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, false); + comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, true); for (var i = 0; i < sourceTypeArguments.length; i++) { - if (!this.sourceIsRelatableToTarget(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + if (!this.sourceIsRelatableToTargetWithNewEnclosingTypes(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, null, isComparingInstantiatedSignatures)) { break; } } - if (i == sourceTypeArguments.length) { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, true); + if (i === sourceTypeArguments.length) { return true; } else { comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); @@ -46776,57 +48141,75 @@ var TypeScript; } } - if (sourceSubstitution.isPrimitive() || target.isPrimitive()) { - return false; - } - if (target.isTypeParameter()) { - if (source.isTypeParameter() && (source === sourceSubstitution)) { - return this.typesAreIdentical(target, source); + if (source.isTypeParameter()) { + if (!source.getConstraint()) { + return this.typesAreIdentical(target, source, context); + } else { + return this.isSourceTypeParameterConstrainedToTargetTypeParameter(source, target); + } } else { if (isComparingInstantiatedSignatures) { - target = this.substituteUpperBoundForType(target); + target = target.getBaseConstraint(this.semanticInfoChain); } else { - return this.typesAreIdentical(target, sourceSubstitution); + return this.typesAreIdentical(target, sourceApparentType, context); } } } - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, false); - - if ((source.kind & 8216 /* SomeInstantiatableType */) && (target.kind & 8216 /* SomeInstantiatableType */) && this.sourceExtendsTarget(source, target, context)) { - return true; - } - - if (this.cachedObjectInterfaceType() && target === this.cachedObjectInterfaceType()) { - return true; - } - - if (this.cachedFunctionInterfaceType() && (sourceSubstitution.getCallSignatures().length || sourceSubstitution.getConstructSignatures().length) && target.hasBase(this.cachedFunctionInterfaceType())) { - return true; - } - - if (target.hasMembers() && !this.sourceMembersAreRelatableToTargetMembers(sourceSubstitution, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); - return false; - } - - if (!this.sourceCallSignaturesAreRelatableToTargetCallSignatures(sourceSubstitution, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); - return false; - } - - if (!this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(sourceSubstitution, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); - return false; - } - - if (!this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(sourceSubstitution, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); + if (sourceApparentType.isPrimitive() || target.isPrimitive()) { return false; } comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, true); + + var symbolsWhenStartedWalkingTypes = context.startWalkingTypes(sourceApparentType, target); + + var needsSourceSubstitutionUpdate = source != sourceApparentType && context.enclosingTypeWalker1._canWalkStructure() && context.enclosingTypeWalker1._getCurrentSymbol() != sourceApparentType; + if (needsSourceSubstitutionUpdate) { + context.enclosingTypeWalker1.setCurrentSymbol(sourceApparentType); + } + + var isRelatable = this.sourceIsRelatableToTargetWorker(source, target, sourceApparentType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + + if (needsSourceSubstitutionUpdate) { + context.enclosingTypeWalker1.setCurrentSymbol(source); + } + context.endWalkingTypes(symbolsWhenStartedWalkingTypes); + + comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, isRelatable); + return isRelatable; + }; + + PullTypeResolver.prototype.isSourceTypeParameterConstrainedToTargetTypeParameter = function (source, target) { + var current = source; + while (current && current.isTypeParameter()) { + if (current === target) { + return true; + } + + current = current.getConstraint(); + } + return false; + }; + + PullTypeResolver.prototype.sourceIsRelatableToTargetWorker = function (source, target, sourceSubstitution, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + if (target.hasMembers() && !this.sourceMembersAreRelatableToTargetMembers(sourceSubstitution, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + return false; + } + + if (!this.sourceCallSignaturesAreRelatableToTargetCallSignatures(sourceSubstitution, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + return false; + } + + if (!this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(sourceSubstitution, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + return false; + } + + if (!this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(sourceSubstitution, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + return false; + } + return true; }; @@ -46835,38 +48218,23 @@ var TypeScript; for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { var targetProp = targetProps[itargetProp]; - var sourceProp = this.getMemberSymbol(targetProp.name, 68147712 /* SomeValue */, source); + + var sourceProp = this._getNamedPropertySymbolOfAugmentedType(targetProp.name, source); this.resolveDeclaredSymbol(targetProp, context); var targetPropType = targetProp.type; - if (sourceProp && sourceProp.anyDeclHasFlag(16 /* Static */) && source.isClass()) { - sourceProp = null; - } - if (!sourceProp) { - if (this.cachedObjectInterfaceType()) { - sourceProp = this.getMemberSymbol(targetProp.name, 68147712 /* SomeValue */, this.cachedObjectInterfaceType()); - } - - if (!sourceProp) { - if (this.cachedFunctionInterfaceType() && (targetPropType.getCallSignatures().length || targetPropType.getConstructSignatures().length)) { - sourceProp = this.getMemberSymbol(targetProp.name, 68147712 /* SomeValue */, this.cachedFunctionInterfaceType()); - } - - if (!sourceProp) { - if (!(targetProp.isOptional)) { - if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - comparisonInfo.flags |= 2 /* RequiredPropertyIsMissing */; - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_is_missing_property_1_from_type_2, [source.toString(enclosingSymbol), targetProp.getScopedNameEx().toString(), target.toString(enclosingSymbol)])); - } - return false; - } - continue; + if (!(targetProp.isOptional)) { + if (comparisonInfo) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + comparisonInfo.flags |= 2 /* RequiredPropertyIsMissing */; + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_is_missing_property_1_from_type_2, [source.toString(enclosingSymbol), targetProp.getScopedNameEx().toString(), target.toString(enclosingSymbol)])); } + return false; } + continue; } if (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { @@ -46878,18 +48246,18 @@ var TypeScript; }; PullTypeResolver.prototype.infinitelyExpandingSourceTypeIsRelatableToTargetType = function (sourceType, targetType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var widenedTargetType = this.widenType(targetType); - var widenedSourceType = this.widenType(sourceType); + var widenedTargetType = targetType.widenedType(this, null, context); + var widenedSourceType = sourceType.widenedType(this, null, context); - if ((widenedSourceType != this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType != this.semanticInfoChain.anyTypeSymbol)) { + if ((widenedSourceType !== this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType !== this.semanticInfoChain.anyTypeSymbol)) { var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); - if (sourceTypeNamedTypeReference != targetTypeNamedTypeReference) { + if (sourceTypeNamedTypeReference !== targetTypeNamedTypeReference) { comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); if (comparisonInfo) { var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_originating_in_inifinitely_expanding_type_reference_do_not_refer_to_same_named_type, [sourceType.getScopedNameEx(enclosingSymbol).toString(), targetType.toString(enclosingSymbol)])); + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_originating_in_infinitely_expanding_type_reference_do_not_refer_to_same_named_type, [sourceType.getScopedNameEx(enclosingSymbol).toString(), targetType.toString(enclosingSymbol)])); } return false; } @@ -46902,11 +48270,11 @@ var TypeScript; return true; } - if (!(sourceTypeArguments && targetTypeArguments) || sourceTypeArguments.length != targetTypeArguments.length) { + if (!(sourceTypeArguments && targetTypeArguments) || sourceTypeArguments.length !== targetTypeArguments.length) { comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); if (comparisonInfo) { var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_originating_in_inifinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)])); + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_originating_in_infinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)])); } return false; } @@ -46915,35 +48283,41 @@ var TypeScript; if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { comparisonInfoTypeArgumentsCheck = new TypeComparisonInfo(comparisonInfo); } - for (var i = 0; i < sourceTypeArguments.length; i++) { - if (!this.sourceIsRelatableToTarget(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + var isRelatable = true; + for (var i = 0; i < sourceTypeArguments.length && isRelatable; i++) { + context.walkTypeArgument(i); + + if (!this.sourceIsRelatableToTargetInEnclosingTypes(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, comparisonInfoTypeArgumentsCheck, isComparingInstantiatedSignatures)) { + isRelatable = false; if (comparisonInfo) { var message; var enclosingSymbol = this.getEnclosingSymbolForAST(ast); if (comparisonInfoTypeArgumentsCheck && comparisonInfoTypeArgumentsCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_originating_in_inifinitely_expanding_type_reference_have_incompatible_type_arguments_NL_2, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol), comparisonInfoTypeArgumentsCheck.message]); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_originating_in_infinitely_expanding_type_reference_have_incompatible_type_arguments_NL_2, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol), comparisonInfoTypeArgumentsCheck.message]); } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_originating_in_inifinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)]); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_originating_in_infinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)]); } comparisonInfo.addMessage(message); } } + + context.postWalkTypeArgument(); } } - comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; + comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, isRelatable); + return isRelatable; }; - PullTypeResolver.prototype.infinitelyExpandingTypesAreIdentical = function (sourceType, targetType) { - var widenedTargetType = this.widenType(targetType); - var widenedSourceType = this.widenType(sourceType); + PullTypeResolver.prototype.infinitelyExpandingTypesAreIdentical = function (sourceType, targetType, context) { + var widenedTargetType = targetType.widenedType(this, null, null); + var widenedSourceType = sourceType.widenedType(this, null, null); - if ((widenedSourceType != this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType != this.semanticInfoChain.anyTypeSymbol)) { + if ((widenedSourceType !== this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType !== this.semanticInfoChain.anyTypeSymbol)) { var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); - if (sourceTypeNamedTypeReference != targetTypeNamedTypeReference) { + if (sourceTypeNamedTypeReference !== targetTypeNamedTypeReference) { this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); return false; } @@ -46956,13 +48330,17 @@ var TypeScript; return true; } - if (!(sourceTypeArguments && targetTypeArguments) || sourceTypeArguments.length != targetTypeArguments.length) { + if (!(sourceTypeArguments && targetTypeArguments) || sourceTypeArguments.length !== targetTypeArguments.length) { this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); return false; } for (var i = 0; i < sourceTypeArguments.length; i++) { - if (!this.typesAreIdentical(sourceTypeArguments[i], targetTypeArguments[i])) { + context.walkTypeArgument(i); + var areIdentical = this.typesAreIdenticalInEnclosingTypes(sourceTypeArguments[i], targetTypeArguments[i], context); + context.postWalkTypeArgument(); + + if (!areIdentical) { this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); return false; } @@ -46974,17 +48352,37 @@ var TypeScript; }; PullTypeResolver.prototype.sourcePropertyIsRelatableToTargetProperty = function (source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var _this = this; + var sourceAndTargetAreConstructors = source.isConstructor() && target.isConstructor(); + + var getNames = function (takeTypesFromPropertyContainers) { + var enclosingSymbol = _this.getEnclosingSymbolForAST(ast); + var sourceType = takeTypesFromPropertyContainers ? sourceProp.getContainer() : source; + var targetType = takeTypesFromPropertyContainers ? targetProp.getContainer() : target; + if (sourceAndTargetAreConstructors) { + sourceType = sourceType.getAssociatedContainerType(); + targetType = targetType.getAssociatedContainerType(); + } + return { + propertyName: targetProp.getScopedNameEx().toString(), + sourceTypeName: sourceType.toString(enclosingSymbol), + targetTypeName: targetType.toString(enclosingSymbol) + }; + }; + var targetPropIsPrivate = targetProp.anyDeclHasFlag(2 /* Private */); var sourcePropIsPrivate = sourceProp.anyDeclHasFlag(2 /* Private */); - if (targetPropIsPrivate != sourcePropIsPrivate) { + if (targetPropIsPrivate !== sourcePropIsPrivate) { if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + var names = getNames(true); + var code; if (targetPropIsPrivate) { - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2, [targetProp.getScopedNameEx().toString(), sourceProp.getContainer().toString(enclosingSymbol), targetProp.getContainer().toString(enclosingSymbol)])); + code = sourceAndTargetAreConstructors ? TypeScript.DiagnosticCode.Static_property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2 : TypeScript.DiagnosticCode.Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2; } else { - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2, [targetProp.getScopedNameEx().toString(), sourceProp.getContainer().toString(enclosingSymbol), targetProp.getContainer().toString(enclosingSymbol)])); + code = sourceAndTargetAreConstructors ? TypeScript.DiagnosticCode.Static_property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2 : TypeScript.DiagnosticCode.Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2; } + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(code, [names.propertyName, names.sourceTypeName, names.targetTypeName])); comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; } return false; @@ -46992,12 +48390,13 @@ var TypeScript; var targetDecl = targetProp.getDeclarations()[0]; var sourceDecl = sourceProp.getDeclarations()[0]; - if (!targetDecl.isEqual(sourceDecl)) { + if (targetDecl !== sourceDecl) { if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + var names = getNames(true); comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_define_property_2_as_private, [sourceProp.getContainer().toString(enclosingSymbol), targetProp.getContainer().toString(enclosingSymbol), targetProp.getScopedNameEx().toString()])); + var code = sourceAndTargetAreConstructors ? TypeScript.DiagnosticCode.Types_0_and_1_define_static_property_2_as_private : TypeScript.DiagnosticCode.Types_0_and_1_define_property_2_as_private; + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(code, [names.sourceTypeName, names.targetTypeName, names.propertyName])); } return false; @@ -47006,9 +48405,9 @@ var TypeScript; if (sourceProp.isOptional && !targetProp.isOptional) { if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + var names = getNames(true); comparisonInfo.flags |= 2 /* RequiredPropertyIsMissing */; - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Property_0_defined_as_optional_in_type_1_but_is_required_in_type_2, [targetProp.getScopedNameEx().toString(), sourceProp.getContainer().toString(enclosingSymbol), targetProp.getContainer().toString(enclosingSymbol)])); + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Property_0_defined_as_optional_in_type_1_but_is_required_in_type_2, [names.propertyName, names.sourceTypeName, names.targetTypeName])); } return false; } @@ -47018,8 +48417,9 @@ var TypeScript; var sourcePropType = sourceProp.type; var targetPropType = targetProp.type; - if (comparisonCache.valueAt(sourcePropType.pullSymbolID, targetPropType.pullSymbolID)) { - return true; + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(sourcePropType, targetPropType, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; } var comparisonInfoPropertyTypeCheck = null; @@ -47027,23 +48427,26 @@ var TypeScript; comparisonInfoPropertyTypeCheck = new TypeComparisonInfo(comparisonInfo); } - if (this.sourceIsRelatableToTargetInEnclosingTypes(sourcePropType, targetPropType, source, target, assignableTo, comparisonCache, ast, context, comparisonInfoPropertyTypeCheck, isComparingInstantiatedSignatures)) { - return true; - } + context.walkMemberTypes(targetProp.name); + var isSourcePropertyRelatableToTargetProperty = this.sourceIsRelatableToTargetInEnclosingTypes(sourcePropType, targetPropType, assignableTo, comparisonCache, ast, context, comparisonInfoPropertyTypeCheck, isComparingInstantiatedSignatures); + context.postWalkMemberTypes(); - if (comparisonInfo) { + if (!isSourcePropertyRelatableToTargetProperty && comparisonInfo) { var enclosingSymbol = this.getEnclosingSymbolForAST(ast); comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; var message; + var names = getNames(false); if (comparisonInfoPropertyTypeCheck && comparisonInfoPropertyTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_property_0_of_types_1_and_2_are_incompatible_NL_3, [targetProp.getScopedNameEx().toString(), source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoPropertyTypeCheck.message]); + var code = sourceAndTargetAreConstructors ? TypeScript.DiagnosticCode.Types_of_static_property_0_of_class_1_and_class_2_are_incompatible_NL_3 : TypeScript.DiagnosticCode.Types_of_property_0_of_types_1_and_2_are_incompatible_NL_3; + message = TypeScript.getDiagnosticMessage(code, [names.propertyName, names.sourceTypeName, names.targetTypeName, comparisonInfoPropertyTypeCheck.message]); } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_property_0_of_types_1_and_2_are_incompatible, [targetProp.getScopedNameEx().toString(), source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + var code = sourceAndTargetAreConstructors ? TypeScript.DiagnosticCode.Types_of_static_property_0_of_class_1_and_class_2_are_incompatible : TypeScript.DiagnosticCode.Types_of_property_0_of_types_1_and_2_are_incompatible; + message = TypeScript.getDiagnosticMessage(code, [names.propertyName, names.sourceTypeName, names.targetTypeName]); } comparisonInfo.addMessage(message); } - return false; + return isSourcePropertyRelatableToTargetProperty; }; PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { @@ -47056,7 +48459,7 @@ var TypeScript; } var sourceCallSigs = source.getCallSignatures(); - if (!this.signatureGroupIsRelatableToTarget(sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { + if (!this.signatureGroupIsRelatableToTarget(source, target, sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { if (comparisonInfo) { var message; var enclosingSymbol = this.getEnclosingSymbolForAST(ast); @@ -47090,7 +48493,7 @@ var TypeScript; } var sourceConstructSigs = source.getConstructSignatures(); - if (!this.signatureGroupIsRelatableToTarget(sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { + if (!this.signatureGroupIsRelatableToTarget(source, target, sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { if (comparisonInfo) { var enclosingSymbol = this.getEnclosingSymbolForAST(ast); var message; @@ -47116,12 +48519,13 @@ var TypeScript; }; PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetIndexSigs = this.getBothKindsOfIndexSignatures(target, context); + var targetIndexSigs = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(target, context); var targetStringSig = targetIndexSigs.stringSignature; var targetNumberSig = targetIndexSigs.numericSignature; if (targetStringSig || targetNumberSig) { - var sourceIndexSigs = this.getBothKindsOfIndexSignatures(source, context); + var sourceIndexSigs = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(source, context); + var enclosingTypeIndexSigs = context.getBothKindOfIndexSignatures(true, false); var sourceStringSig = sourceIndexSigs.stringSignature; var sourceNumberSig = sourceIndexSigs.numericSignature; @@ -47133,7 +48537,9 @@ var TypeScript; if (targetStringSig) { if (sourceStringSig) { - comparable = this.signatureIsAssignableToTarget(sourceStringSig, targetStringSig, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, true); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetStringSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); } else { comparable = false; } @@ -47141,9 +48547,13 @@ var TypeScript; if (comparable && targetNumberSig) { if (sourceNumberSig) { - comparable = this.signatureIsAssignableToTarget(sourceNumberSig, targetNumberSig, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, false, false); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceNumberSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); } else if (sourceStringSig) { - comparable = this.sourceIsAssignableToTarget(sourceStringSig.returnType, targetNumberSig.returnType, ast, context, comparisonInfoSignatuesTypeCheck); + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, false); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); } else { comparable = false; } @@ -47168,7 +48578,7 @@ var TypeScript; return true; }; - PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (sourceSG, targetSG, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (source, target, sourceSG, targetSG, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { if (sourceSG === targetSG) { return true; } @@ -47177,27 +48587,37 @@ var TypeScript; return false; } - var mSig = null; - var nSig = null; var foundMatch = false; var targetExcludeDefinition = targetSG.length > 1; var sourceExcludeDefinition = sourceSG.length > 1; + var sigsCompared = 0; + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo, true); + comparisonInfoSignatuesTypeCheck.message = comparisonInfo.message; + } for (var iMSig = 0; iMSig < targetSG.length; iMSig++) { - mSig = targetSG[iMSig]; + var mSig = targetSG[iMSig]; if (mSig.isStringConstantOverloadSignature() || (targetExcludeDefinition && mSig.isDefinition())) { continue; } for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { - nSig = sourceSG[iNSig]; + var nSig = sourceSG[iNSig]; if (nSig.isStringConstantOverloadSignature() || (sourceExcludeDefinition && nSig.isDefinition())) { continue; } - if (this.signatureIsRelatableToTarget(nSig, mSig, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + context.walkSignatures(nSig.kind, iNSig, iMSig); + var isSignatureRelatableToTarget = this.signatureIsRelatableToTarget(nSig, mSig, assignableTo, comparisonCache, ast, context, sigsCompared == 0 ? comparisonInfoSignatuesTypeCheck : null, isComparingInstantiatedSignatures); + context.postWalkSignatures(); + + sigsCompared++; + + if (isSignatureRelatableToTarget) { foundMatch = true; break; } @@ -47207,6 +48627,11 @@ var TypeScript; foundMatch = false; continue; } + + if (comparisonInfo && sigsCompared == 1) { + comparisonInfo.message = comparisonInfoSignatuesTypeCheck.message; + } + return false; } @@ -47214,6 +48639,19 @@ var TypeScript; }; PullTypeResolver.prototype.signatureIsRelatableToTarget = function (sourceSig, targetSig, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(sourceSig, targetSig, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; + } + + comparisonCache.setValueAt(sourceSig.pullSymbolID, targetSig.pullSymbolID, true); + var isRelatable = this.signatureIsRelatableToTargetWorker(sourceSig, targetSig, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + comparisonCache.setValueAt(sourceSig.pullSymbolID, targetSig.pullSymbolID, isRelatable); + return isRelatable; + }; + + PullTypeResolver.prototype.signatureIsRelatableToTargetWorker = function (sourceSig, targetSig, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var _this = this; var sourceParameters = sourceSig.parameters; var targetParameters = targetSig.parameters; @@ -47221,43 +48659,37 @@ var TypeScript; return false; } - var targetVarArgCount = targetSig.nonOptionalParamCount; - var sourceVarArgCount = sourceSig.nonOptionalParamCount; + var targetNonOptionalParamCount = targetSig.nonOptionalParamCount; + var sourceNonOptionalParamCount = sourceSig.nonOptionalParamCount; - if (sourceVarArgCount > targetVarArgCount) { + if (!targetSig.hasVarArgs && sourceNonOptionalParamCount > targetParameters.length) { if (comparisonInfo) { comparisonInfo.flags |= 3 /* SourceSignatureHasTooManyParameters */; - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signature_expects_0_or_fewer_parameters, [targetVarArgCount])); + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signature_expects_0_or_fewer_parameters, [targetParameters.length])); } return false; } - if (sourceSig.isGeneric()) { - var rootSourceSig = sourceSig.getRootSymbol(); - var rootTargetSig = targetSig.getRootSymbol(); - - if (comparisonCache.valueAt(rootSourceSig.pullSymbolID, rootTargetSig.pullSymbolID) != undefined) { - return true; - } - - comparisonCache.setValueAt(rootSourceSig.pullSymbolID, rootTargetSig.pullSymbolID, false); - - sourceSig = this.instantiateSignatureInContext(sourceSig, targetSig, context); - - if (!sourceSig) { - return false; - } else { - sourceParameters = sourceSig.parameters; - } + if (this.signaturesAreIdentical(sourceSig, targetSig, context)) { + return true; } - comparisonCache.setValueAt(sourceSig.pullSymbolID, targetSig.pullSymbolID, false); + if (targetSig.isGeneric()) { + targetSig = this.instantiateSignatureToAny(targetSig); + } + + if (sourceSig.isGeneric()) { + sourceSig = this.instantiateSignatureToAny(sourceSig); + } var sourceReturnType = sourceSig.returnType; var targetReturnType = targetSig.returnType; - if (targetReturnType != this.semanticInfoChain.voidTypeSymbol) { - if (!this.sourceIsRelatableToTargetInEnclosingTypes(sourceReturnType, targetReturnType, sourceSig.functionType, targetSig.functionType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + if (targetReturnType !== this.semanticInfoChain.voidTypeSymbol) { + context.walkReturnTypes(); + var returnTypesAreRelatable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceReturnType, targetReturnType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.postWalkReturnTypes(); + if (!returnTypesAreRelatable) { if (comparisonInfo) { comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; } @@ -47266,51 +48698,24 @@ var TypeScript; } } - var len = (sourceVarArgCount < targetVarArgCount && (sourceSig.hasVarArgs || (sourceParameters.length > sourceVarArgCount))) ? targetVarArgCount : sourceVarArgCount; - - if (!len) { - len = (sourceParameters.length < targetParameters.length) ? sourceParameters.length : targetParameters.length; - } - - var sourceParamType = null; - var targetParamType = null; - var sourceParamName = ""; - var targetParamName = ""; - - for (var iSource = 0, iTarget = 0; iSource < len; iSource++, iTarget++) { - if (iSource < sourceParameters.length && (!sourceSig.hasVarArgs || iSource < sourceVarArgCount)) { - sourceParamType = sourceParameters[iSource].type; - sourceParamName = sourceParameters[iSource].name; - } else if (iSource === sourceVarArgCount) { - sourceParamType = sourceParameters[iSource].type; - if (sourceParamType.isArrayNamedTypeReference()) { - sourceParamType = sourceParamType.getElementType(); - } - sourceParamName = sourceParameters[iSource].name; + return targetSig.forAllCorrespondingParameterTypesInThisAndOtherSignature(sourceSig, function (targetParamType, sourceParamType, iParam) { + context.walkParameterTypes(iParam); + var areParametersRelatable = _this.sourceIsRelatableToTargetInEnclosingTypes(sourceParamType, targetParamType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + if (!areParametersRelatable) { + context.swapEnclosingTypeWalkers(); + areParametersRelatable = _this.sourceIsRelatableToTargetInEnclosingTypes(targetParamType, sourceParamType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.swapEnclosingTypeWalkers(); } + context.postWalkParameterTypes(); - if (iTarget < targetParameters.length && !targetSig.hasVarArgs && (!targetVarArgCount || (iTarget < targetVarArgCount))) { - targetParamType = targetParameters[iTarget].type; - targetParamName = targetParameters[iTarget].name; - } else if (targetSig.hasVarArgs && iTarget === targetVarArgCount) { - targetParamType = targetParameters[iTarget].type; - - if (targetParamType.isArrayNamedTypeReference()) { - targetParamType = targetParamType.getElementType(); - } - targetParamName = targetParameters[iTarget].name; - } - - if (!(this.sourceIsRelatableToTargetInEnclosingTypes(sourceParamType, targetParamType, sourceSig.functionType, targetSig.functionType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) || this.sourceIsRelatableToTargetInEnclosingTypes(targetParamType, sourceParamType, targetSig.functionType, sourceSig.functionType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures))) { + if (!areParametersRelatable) { if (comparisonInfo) { comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; } - - return false; } - } - return true; + return areParametersRelatable; + }); }; PullTypeResolver.prototype.resolveOverloads = function (application, group, haveTypeArgumentsAtCallSite, context, diagnostics) { @@ -47324,7 +48729,8 @@ var TypeScript; return false; } - if (haveTypeArgumentsAtCallSite && !signature.isGeneric()) { + var rootSignature = signature.getRootSymbol(); + if (haveTypeArgumentsAtCallSite && !rootSignature.isGeneric()) { return false; } @@ -47423,13 +48829,13 @@ var TypeScript; return 1 /* AssignableButWithProvisionalErrors */; } else if (arg.kind() === 219 /* SimpleArrowFunctionExpression */) { var simpleArrowFunction = arg; - return this.overloadIsApplicableForAnyFunctionExpressionArgument(paramType, arg, null, TypeScript.Parameters.fromIdentifier(simpleArrowFunction.identifier), null, simpleArrowFunction.block, simpleArrowFunction.expression, argIndex, context, comparisonInfo); + return this.overloadIsApplicableForAnyFunctionExpressionArgument(paramType, arg, null, TypeScript.ASTHelpers.parametersFromIdentifier(simpleArrowFunction.identifier), null, simpleArrowFunction.block, simpleArrowFunction.expression, argIndex, context, comparisonInfo); } else if (arg.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { var arrowFunction = arg; - return this.overloadIsApplicableForAnyFunctionExpressionArgument(paramType, arg, arrowFunction.callSignature.typeParameterList, TypeScript.Parameters.fromParameterList(arrowFunction.callSignature.parameterList), TypeScript.getType(arrowFunction), arrowFunction.block, arrowFunction.expression, argIndex, context, comparisonInfo); + return this.overloadIsApplicableForAnyFunctionExpressionArgument(paramType, arg, arrowFunction.callSignature.typeParameterList, TypeScript.ASTHelpers.parametersFromParameterList(arrowFunction.callSignature.parameterList), TypeScript.ASTHelpers.getType(arrowFunction), arrowFunction.block, arrowFunction.expression, argIndex, context, comparisonInfo); } else if (arg.kind() === 222 /* FunctionExpression */) { var functionExpression = arg; - return this.overloadIsApplicableForAnyFunctionExpressionArgument(paramType, arg, functionExpression.callSignature.typeParameterList, TypeScript.Parameters.fromParameterList(functionExpression.callSignature.parameterList), TypeScript.getType(functionExpression), functionExpression.block, null, argIndex, context, comparisonInfo); + return this.overloadIsApplicableForAnyFunctionExpressionArgument(paramType, arg, functionExpression.callSignature.typeParameterList, TypeScript.ASTHelpers.parametersFromParameterList(functionExpression.callSignature.parameterList), TypeScript.ASTHelpers.getType(functionExpression), functionExpression.block, null, argIndex, context, comparisonInfo); } else if (arg.kind() === 215 /* ObjectLiteralExpression */) { return this.overloadIsApplicableForObjectLiteralArgument(paramType, arg, argIndex, context, comparisonInfo); } else if (arg.kind() === 214 /* ArrayLiteralExpression */) { @@ -47444,13 +48850,13 @@ var TypeScript; return 2 /* AssignableWithNoProvisionalErrors */; } - context.pushContextualType(paramType, true, null); + context.pushProvisionalType(paramType); var argSym = this.resolveAnyFunctionExpression(arg, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, true, context); var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - context.popContextualType(); + context.popAnyContextualType(); return applicabilityStatus; }; @@ -47460,12 +48866,12 @@ var TypeScript; return 2 /* AssignableWithNoProvisionalErrors */; } - context.pushContextualType(paramType, true, null); + context.pushProvisionalType(paramType); var argSym = this.resolveObjectLiteralExpression(arg, true, context); var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - context.popContextualType(); + context.popAnyContextualType(); return applicabilityStatus; }; @@ -47475,12 +48881,12 @@ var TypeScript; return 2 /* AssignableWithNoProvisionalErrors */; } - context.pushContextualType(paramType, true, null); + context.pushProvisionalType(paramType); var argSym = this.resolveArrayLiteralExpression(arg, true, context); var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - context.popContextualType(); + context.popAnyContextualType(); return applicabilityStatus; }; @@ -47516,92 +48922,34 @@ var TypeScript; return 0 /* NotAssignable */; }; - PullTypeResolver.prototype.inferArgumentTypesForSignature = function (signature, argContext, comparisonInfo, context) { - var cxt = null; + PullTypeResolver.prototype.inferArgumentTypesForSignature = function (argContext, comparisonInfo, context) { + var inferenceResultTypes = argContext.inferTypeArguments(); + var typeParameters = argContext.signatureBeingInferred.getTypeParameters(); + TypeScript.Debug.assert(typeParameters.length == inferenceResultTypes.length); - var parameters = signature.parameters; - var typeParameters = signature.getTypeParameters(); - - var parameterType = null; - var argCount = argContext.getInferenceArgumentCount(); - - for (var i = 0; i < typeParameters.length; i++) { - argContext.addInferenceRoot(typeParameters[i]); - } - - for (var i = 0; i < argCount; i++) { - if (i >= parameters.length) { - break; - } - - parameterType = parameters[i].type; - - if (signature.hasVarArgs && (i >= signature.nonOptionalParamCount - 1) && parameterType.isArrayNamedTypeReference()) { - parameterType = parameterType.getElementType(); - } - - var inferenceCandidates = argContext.getInferenceCandidates(); - - if (inferenceCandidates.length) { - for (var j = 0; j < inferenceCandidates.length; j++) { - argContext.resetRelationshipCache(); - var substitutions = inferenceCandidates[j]; - - context.pushContextualType(parameterType, true, substitutions); - - this.relateTypeToTypeParameters(argContext.getArgumentTypeSymbolAtIndex(i, context), parameterType, false, argContext, context); - - cxt = context.popContextualType(); - } - } else { - context.pushContextualType(parameterType, true, []); - - this.relateTypeToTypeParameters(argContext.getArgumentTypeSymbolAtIndex(i, context), parameterType, false, argContext, context); - - cxt = context.popContextualType(); - } - } - - var inferenceResults = argContext.inferArgumentTypes(this, context); - - if (inferenceResults.unfit) { - return null; - } - - var resultTypes = []; - - for (var i = 0; i < typeParameters.length; i++) { - for (var j = 0; j < inferenceResults.results.length; j++) { - if ((inferenceResults.results[j].param == typeParameters[i]) && inferenceResults.results[j].type) { - resultTypes[resultTypes.length] = inferenceResults.results[j].type; - break; + var typeReplacementMapForConstraints = null; + for (var i = 0; i < inferenceResultTypes.length; i++) { + if (typeParameters[i].getConstraint()) { + typeReplacementMapForConstraints = typeReplacementMapForConstraints || TypeScript.PullInstantiationHelpers.createTypeParameterArgumentMap(typeParameters, inferenceResultTypes); + var associatedConstraint = this.instantiateType(typeParameters[i].getConstraint(), typeReplacementMapForConstraints); + if (!this.sourceIsAssignableToTargetWithNewEnclosingTypes(inferenceResultTypes[i], associatedConstraint, null, context, null, false)) { + inferenceResultTypes[i] = associatedConstraint; } } } - if (!argCount && !resultTypes.length && typeParameters.length) { - for (var i = 0; i < typeParameters.length; i++) { - resultTypes[resultTypes.length] = this.semanticInfoChain.emptyTypeSymbol; - } - } else if (resultTypes.length < typeParameters.length) { - for (var i = resultTypes.length; i < typeParameters.length; i++) { - resultTypes[i] = this.semanticInfoChain.emptyTypeSymbol; - } - } - - var inferringAtCallExpression = argContext.argumentASTs && argContext.argumentASTs.parent && argContext.argumentASTs.parent.kind() === 226 /* ArgumentList */ && (argContext.argumentASTs.parent.parent.kind() === 213 /* InvocationExpression */ || argContext.argumentASTs.parent.parent.kind() === 216 /* ObjectCreationExpression */); - - if (inferringAtCallExpression) { - if (!this.typeParametersAreInScopeAtArgumentList(typeParameters, argContext.argumentASTs)) { - for (var i = 0; i < resultTypes.length; i++) { - if (resultTypes[i].wrapsSomeTypeParameter(argContext.candidateCache)) { - resultTypes[i] = this.semanticInfoChain.emptyTypeSymbol; + if (argContext.isInvocationInferenceContext()) { + var invocationContext = argContext; + if (!this.typeParametersAreInScopeAtArgumentList(typeParameters, invocationContext.argumentASTs)) { + for (var i = 0; i < inferenceResultTypes.length; i++) { + if (inferenceResultTypes[i].wrapsSomeTypeParameter(argContext.candidateCache)) { + inferenceResultTypes[i] = this.semanticInfoChain.anyTypeSymbol; } } } } - return resultTypes; + return inferenceResultTypes; }; PullTypeResolver.prototype.typeParametersAreInScopeAtArgumentList = function (typeParameters, args) { @@ -47610,19 +48958,23 @@ var TypeScript; return enclosingDecl.getParentPath().indexOf(typeParameterParentDecl) > -1; }; - PullTypeResolver.prototype.relateTypeToTypeParametersInEnclosingType = function (expressionType, parameterType, expressionTypeEnclosingType, parameterTypeEnclosingType, shouldFix, argContext, context) { + PullTypeResolver.prototype.relateTypeToTypeParametersInEnclosingType = function (expressionType, parameterType, argContext, context) { if (expressionType && parameterType) { - var expressionTypeGenerativeTypeClassification = expressionTypeEnclosingType ? expressionType.getGenerativeTypeClassification(expressionTypeEnclosingType) : 0 /* Unknown */; - var parameterTypeGenerativeTypeClassification = parameterTypeEnclosingType ? parameterType.getGenerativeTypeClassification(parameterTypeEnclosingType) : 0 /* Unknown */; - if (expressionTypeGenerativeTypeClassification == 3 /* InfinitelyExpanding */ || parameterTypeGenerativeTypeClassification == 3 /* InfinitelyExpanding */) { - this.relateInifinitelyExpandingTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, context); + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + this.relateInifinitelyExpandingTypeToTypeParameters(expressionType, parameterType, argContext, context); return; } } - this.relateTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, context); + this.relateTypeToTypeParameters(expressionType, parameterType, argContext, context); }; - PullTypeResolver.prototype.relateTypeToTypeParameters = function (expressionType, parameterType, shouldFix, argContext, context) { + PullTypeResolver.prototype.relateTypeToTypeParametersWithNewEnclosingTypes = function (expressionType, parameterType, argContext, context) { + var enclosingTypeWalkers = context.resetEnclosingTypeWalkers(); + this.relateTypeToTypeParameters(expressionType, parameterType, argContext, context); + context.setEnclosingTypeWalkers(enclosingTypeWalkers); + }; + + PullTypeResolver.prototype.relateTypeToTypeParameters = function (expressionType, parameterType, argContext, context) { if (!expressionType || !parameterType) { return; } @@ -47632,82 +48984,73 @@ var TypeScript; } if (parameterType.isTypeParameter()) { - argContext.addCandidateForInference(parameterType, expressionType, shouldFix); + var typeParameter = parameterType; + argContext.addCandidateForInference(typeParameter, expressionType); return; } - var parameterDeclarations = parameterType.getDeclarations(); - var expressionDeclarations = expressionType.getDeclarations(); - - if (!parameterType.isArrayNamedTypeReference() && parameterDeclarations.length && expressionDeclarations.length && !(parameterType.isTypeParameter() || expressionType.isTypeParameter()) && (parameterDeclarations[0].isEqual(expressionDeclarations[0]) || (expressionType.isGeneric() && parameterType.isGeneric() && this.sourceIsSubtypeOfTarget(this.instantiateTypeToAny(expressionType, context), this.instantiateTypeToAny(parameterType, context), null, context, null))) && expressionType.isGeneric()) { - this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, context); - } - - if (expressionType.isArrayNamedTypeReference() && parameterType.isArrayNamedTypeReference()) { - this.relateArrayTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, context); - + if (parameterType.isNamedTypeSymbol() && !parameterType.isGeneric() && !parameterType.getTypeArguments()) { return; } - this.relateObjectTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, context); - }; - - PullTypeResolver.prototype.relateTypeArgumentsOfTypeToTypeParameters = function (expressionType, parameterType, shouldFix, argContext, context) { - var typeParameters = parameterType.getTypeArgumentsOrTypeParameters(); - var typeArguments = expressionType.getTypeArguments(); - - if (!typeArguments) { - typeParameters = parameterType.getTypeArguments(); - typeArguments = expressionType.getTypeArgumentsOrTypeParameters(); - } - - if (typeParameters && typeArguments && typeParameters.length === typeArguments.length) { - for (var i = 0; i < typeParameters.length; i++) { - if (typeArguments[i] != typeParameters[i]) { - this.relateTypeToTypeParameters(typeArguments[i], typeParameters[i], true, argContext, context); - } - } + if (TypeScript.PullInstantiationHelpers.twoTypesAreInstantiationsOfSameNamedGenericType(expressionType, parameterType)) { + this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, argContext, context); + } else { + var symbolsWhenStartedWalkingTypes = context.startWalkingTypes(expressionType, parameterType); + this.relateObjectTypeToTypeParameters(expressionType, parameterType, argContext, context); + context.endWalkingTypes(symbolsWhenStartedWalkingTypes); } }; - PullTypeResolver.prototype.relateInifinitelyExpandingTypeToTypeParameters = function (expressionType, parameterType, shouldFix, argContext, context) { + PullTypeResolver.prototype.relateTypeArgumentsOfTypeToTypeParameters = function (expressionType, parameterType, argContext, context) { + var parameterSideTypeArguments = parameterType.getTypeArguments(); + var argumentSideTypeArguments = expressionType.getTypeArguments(); + + TypeScript.Debug.assert(parameterSideTypeArguments && argumentSideTypeArguments && parameterSideTypeArguments.length === argumentSideTypeArguments.length); + for (var i = 0; i < parameterSideTypeArguments.length; i++) { + this.relateTypeToTypeParametersWithNewEnclosingTypes(argumentSideTypeArguments[i], parameterSideTypeArguments[i], argContext, context); + } + }; + + PullTypeResolver.prototype.relateInifinitelyExpandingTypeToTypeParameters = function (expressionType, parameterType, argContext, context) { if (!expressionType || !parameterType) { return; } var expressionTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(expressionType); var parameterTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(parameterType); - if (expressionTypeNamedTypeReference != parameterTypeNamedTypeReference) { + if (expressionTypeNamedTypeReference !== parameterTypeNamedTypeReference) { return; } var expressionTypeTypeArguments = expressionType.getTypeArguments(); - var parameterTypeParameters = parameterType.getTypeParameters(); + var parameterTypeArguments = parameterType.getTypeArguments(); - if (expressionTypeTypeArguments && parameterTypeParameters && expressionTypeTypeArguments.length === parameterTypeParameters.length) { + if (expressionTypeTypeArguments && parameterTypeArguments && expressionTypeTypeArguments.length === parameterTypeArguments.length) { for (var i = 0; i < expressionTypeTypeArguments.length; i++) { - this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, context); + this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, argContext, context); } } }; PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, context) { - var expressionParams = expressionSignature.parameters; + var _this = this; var expressionReturnType = expressionSignature.returnType; - - var parameterParams = parameterSignature.parameters; var parameterReturnType = parameterSignature.returnType; - var len = parameterParams.length < expressionParams.length ? parameterParams.length : expressionParams.length; + parameterSignature.forAllCorrespondingParameterTypesInThisAndOtherSignature(expressionSignature, function (parameterSignatureParameterType, expressionSignatureParameterType, i) { + context.walkParameterTypes(i); + _this.relateTypeToTypeParametersInEnclosingType(expressionSignatureParameterType, parameterSignatureParameterType, argContext, context); + context.postWalkParameterTypes(); + return true; + }); - for (var i = 0; i < len; i++) { - this.relateTypeToTypeParametersInEnclosingType(expressionParams[i].type, parameterParams[i].type, expressionSignature.functionType, parameterSignature.functionType, true, argContext, context); - } - - this.relateTypeToTypeParametersInEnclosingType(expressionReturnType, parameterReturnType, expressionSignature.functionType, parameterSignature.functionType, false, argContext, context); + context.walkReturnTypes(); + this.relateTypeToTypeParametersInEnclosingType(expressionReturnType, parameterReturnType, argContext, context); + context.postWalkReturnTypes(); }; - PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, shouldFix, argContext, context) { + PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, argContext, context) { var parameterTypeMembers = parameterType.getMembers(); var parameterSignatures; @@ -47718,58 +49061,98 @@ var TypeScript; return; } - var objectTypeArguments = objectType.getTypeArguments(); - var parameterTypeParameters = parameterType.getTypeParameters(); - - if (objectTypeArguments) { - if (objectTypeArguments.length === parameterTypeParameters.length) { - for (var i = 0; i < objectTypeArguments.length; i++) { - argContext.addCandidateForInference(parameterTypeParameters[i], objectTypeArguments[i], shouldFix); - } - } else if (parameterType == this.semanticInfoChain.anyTypeSymbol) { - for (var i = 0; i < objectTypeArguments.length; i++) { - this.relateTypeToTypeParameters(parameterType, objectTypeArguments[i], shouldFix, argContext, context); - } - } - } - for (var i = 0; i < parameterTypeMembers.length; i++) { - objectMember = this.getMemberSymbol(parameterTypeMembers[i].name, 68147712 /* SomeValue */, objectType); + objectMember = this.getNamedPropertySymbol(parameterTypeMembers[i].name, 68147712 /* SomeValue */, objectType); if (objectMember) { - this.relateTypeToTypeParametersInEnclosingType(objectMember.type, parameterTypeMembers[i].type, objectType, parameterType, shouldFix, argContext, context); + this.resolveDeclaredSymbol(objectMember); + this.resolveDeclaredSymbol(parameterTypeMembers[i]); + context.walkMemberTypes(parameterTypeMembers[i].name); + this.relateTypeToTypeParametersInEnclosingType(objectMember.type, parameterTypeMembers[i].type, argContext, context); + context.postWalkMemberTypes(); } } - parameterSignatures = parameterType.getCallSignatures(); - objectSignatures = objectType.getCallSignatures(); + this.relateSignatureGroupToTypeParameters(objectType.getCallSignatures(), parameterType.getCallSignatures(), 1048576 /* CallSignature */, argContext, context); - if ((parameterSignatures.length == 1) && (objectSignatures.length == 1) && !objectSignatures[0].isGeneric() && (parameterSignatures[0].nonOptionalParamCount >= objectSignatures[0].nonOptionalParamCount)) { - this.relateFunctionSignatureToTypeParameters(objectSignatures[0], parameterSignatures[0], argContext, context); - } + this.relateSignatureGroupToTypeParameters(objectType.getConstructSignatures(), parameterType.getConstructSignatures(), 2097152 /* ConstructSignature */, argContext, context); - parameterSignatures = parameterType.getConstructSignatures(); - objectSignatures = objectType.getConstructSignatures(); - - if ((parameterSignatures.length == 1) && (objectSignatures.length == 1) && !objectSignatures[0].isGeneric() && (parameterSignatures[0].nonOptionalParamCount >= objectSignatures[0].nonOptionalParamCount)) { - this.relateFunctionSignatureToTypeParameters(objectSignatures[0], parameterSignatures[0], argContext, context); - } - - var parameterIndexSignatures = this.getBothKindsOfIndexSignatures(parameterType, context); - var objectIndexSignatures = this.getBothKindsOfIndexSignatures(objectType, context); + var parameterIndexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(parameterType, context); + var objectIndexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(objectType, context); + var indexSigInfo = context.getBothKindOfIndexSignatures(false, false); if (parameterIndexSignatures.stringSignature && objectIndexSignatures.stringSignature) { + context.walkIndexSignatureReturnTypes(indexSigInfo, true, true, true); this.relateFunctionSignatureToTypeParameters(objectIndexSignatures.stringSignature, parameterIndexSignatures.stringSignature, argContext, context); + context.postWalkIndexSignatureReturnTypes(true); } if (parameterIndexSignatures.numericSignature && objectIndexSignatures.numericSignature) { + context.walkIndexSignatureReturnTypes(indexSigInfo, false, false, true); this.relateFunctionSignatureToTypeParameters(objectIndexSignatures.numericSignature, parameterIndexSignatures.numericSignature, argContext, context); + context.postWalkIndexSignatureReturnTypes(true); } }; - PullTypeResolver.prototype.relateArrayTypeToTypeParameters = function (argArrayType, parameterArrayType, shouldFix, argContext, context) { - var argElement = argArrayType.getElementType(); - var paramElement = parameterArrayType.getElementType(); + PullTypeResolver.prototype.relateSignatureGroupToTypeParameters = function (argumentSignatures, parameterSignatures, signatureKind, argContext, context) { + for (var i = 0; i < parameterSignatures.length; i++) { + var paramSignature = parameterSignatures[i]; + if (argumentSignatures.length > 0 && paramSignature.isGeneric()) { + paramSignature = this.instantiateSignatureToAny(paramSignature); + } + for (var j = 0; j < argumentSignatures.length; j++) { + var argumentSignature = argumentSignatures[j]; + if (argumentSignature.nonOptionalParamCount > paramSignature.nonOptionalParamCount) { + continue; + } - this.relateTypeToTypeParameters(argElement, paramElement, shouldFix, argContext, context); + if (argumentSignature.isGeneric()) { + argumentSignature = this.instantiateSignatureToAny(argumentSignature); + } + + context.walkSignatures(signatureKind, j, i); + this.relateFunctionSignatureToTypeParameters(argumentSignature, paramSignature, argContext, context); + context.postWalkSignatures(); + } + } + }; + + PullTypeResolver.prototype.alterPotentialGenericFunctionTypeToInstantiatedFunctionTypeForTypeArgumentInference = function (expressionSymbol, context) { + var inferentialType = context.getContextualType(); + TypeScript.Debug.assert(inferentialType); + var expressionType = expressionSymbol.type; + if (this.isFunctionTypeWithExactlyOneCallSignatureAndNoOtherMembers(expressionType, true) && this.isFunctionTypeWithExactlyOneCallSignatureAndNoOtherMembers(inferentialType, false)) { + var genericExpressionSignature = expressionType.getCallSignatures()[0]; + var contextualSignature = inferentialType.getCallSignatures()[0]; + + var instantiatedSignature = this.instantiateSignatureInContext(genericExpressionSignature, contextualSignature, context, true); + if (instantiatedSignature === null) { + return expressionSymbol; + } + + var newType = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + newType.appendCallSignature(instantiatedSignature); + return newType; + } + + return expressionSymbol; + }; + + PullTypeResolver.prototype.isFunctionTypeWithExactlyOneCallSignatureAndNoOtherMembers = function (type, callSignatureShouldBeGeneric) { + TypeScript.Debug.assert(type); + if (type.getCallSignatures().length !== 1) { + return false; + } + + var callSignatureIsGeneric = type.getCallSignatures()[0].isGeneric(); + if (callSignatureIsGeneric !== callSignatureShouldBeGeneric) { + return false; + } + + var typeHasOtherMembers = type.getConstructSignatures().length || type.getIndexSignatures().length || type.getAllMembers(68147712 /* SomeValue */, 0 /* all */).length; + if (typeHasOtherMembers) { + return false; + } + + return true; }; PullTypeResolver.prototype.instantiateTypeToAny = function (typeToSpecialize, context) { @@ -47806,6 +49189,32 @@ var TypeScript; return type; }; + PullTypeResolver.prototype.instantiateSignatureToAny = function (signature) { + var typeParameters = signature.getTypeParameters(); + if (!this._cachedAnyTypeArgs) { + this._cachedAnyTypeArgs = [ + [this.semanticInfoChain.anyTypeSymbol], + [this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol], + [this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol], + [this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol], + [this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol] + ]; + } + + if (typeParameters.length < this._cachedAnyTypeArgs.length) { + var typeArguments = this._cachedAnyTypeArgs[typeParameters.length - 1]; + } else { + var typeArguments = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeArguments[typeArguments.length] = this.semanticInfoChain.anyTypeSymbol; + } + } + + var typeParameterArgumentMap = TypeScript.PullInstantiationHelpers.createTypeParameterArgumentMap(typeParameters, typeArguments); + return this.instantiateSignature(signature, typeParameterArgumentMap); + }; + PullTypeResolver.typeCheck = function (compilationSettings, semanticInfoChain, document) { var sourceUnit = document.sourceUnit(); @@ -47826,66 +49235,23 @@ var TypeScript; }; PullTypeResolver.prototype.validateVariableDeclarationGroups = function (enclosingDecl, context) { - var importDeclarationNames = null; - if (enclosingDecl.kind & (4 /* Container */ | 32 /* DynamicModule */ | 1 /* Script */)) { - var childDecls = enclosingDecl.getChildDecls(); - for (var i = 0, n = childDecls.length; i < n; i++) { - var childDecl = childDecls[i]; - if (childDecl.kind === 128 /* TypeAlias */) { - importDeclarationNames = importDeclarationNames || TypeScript.createIntrinsicsObject(); - importDeclarationNames[childDecl.name] = true; - } - } - } - - var declGroups = enclosingDecl.getVariableDeclGroups(); - - for (var i = 0, i_max = declGroups.length; i < i_max; i++) { - var firstSymbol = null; - var firstSymbolType = null; - - if (enclosingDecl.kind === 1 /* Script */ && declGroups[i].length) { - var name = declGroups[i][0].name; - var candidateSymbol = this.semanticInfoChain.findTopLevelSymbol(name, 512 /* Variable */, enclosingDecl); - if (candidateSymbol && candidateSymbol.isResolved) { - if (!candidateSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */)) { - firstSymbol = candidateSymbol; - firstSymbolType = candidateSymbol.type; - } - } - - var importSymbol = this.semanticInfoChain.findTopLevelSymbol(name, 128 /* TypeAlias */, null); - if (importSymbol && importSymbol.isAlias()) { - importDeclarationNames = importDeclarationNames || TypeScript.createIntrinsicsObject(); - } + var _this = this; + this.scanVariableDeclarationGroups(enclosingDecl, function (_) { + }, function (subsequentDecl, firstSymbol) { + if (TypeScript.hasFlag(subsequentDecl.kind, 2048 /* Parameter */) || TypeScript.hasFlag(subsequentDecl.flags, 8388608 /* PropertyParameter */)) { + return; } - for (var j = 0, j_max = declGroups[i].length; j < j_max; j++) { - var decl = declGroups[i][j]; - var boundDeclAST = this.semanticInfoChain.getASTForDecl(decl); + var boundDeclAST = _this.semanticInfoChain.getASTForDecl(subsequentDecl); - var name = decl.name; + var symbol = subsequentDecl.getSymbol(); + var symbolType = symbol.type; + var firstSymbolType = firstSymbol.type; - if (importDeclarationNames && importDeclarationNames[name]) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(boundDeclAST, TypeScript.DiagnosticCode.Variable_declaration_cannot_have_the_same_name_as_an_import_declaration)); - continue; - } - - var symbol = decl.getSymbol(); - var symbolType = symbol.type; - - if (j === 0 && !firstSymbol) { - firstSymbol = symbol; - firstSymbolType = symbolType; - continue; - } - - if (symbolType && firstSymbolType && symbolType !== firstSymbolType && !this.typesAreIdentical(symbolType, firstSymbolType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(boundDeclAST, TypeScript.DiagnosticCode.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, [symbol.getScopedName(), firstSymbolType.toString(), symbolType.toString()])); - continue; - } + if (symbolType && firstSymbolType && symbolType !== firstSymbolType && !_this.typesAreIdentical(symbolType, firstSymbolType, context)) { + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(boundDeclAST, TypeScript.DiagnosticCode.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, [symbol.getScopedName(), firstSymbolType.toString(firstSymbol), symbolType.toString(symbol)])); } - } + }); }; PullTypeResolver.prototype.typeCheckFunctionOverloads = function (funcDecl, context, signature, allSignatures) { @@ -47906,13 +49272,19 @@ var TypeScript; } if (!signature.isDefinition()) { + var signatureParentDecl = signature.getDeclarations()[0].getParentDecl(); for (var i = 0; i < allSignatures.length; i++) { if (allSignatures[i] === signature) { break; } - if (this.signaturesAreIdentical(allSignatures[i], signature, false)) { - if (!this.typesAreIdentical(allSignatures[i].returnType, signature.returnType)) { + var allSignaturesParentDecl = allSignatures[i].getDeclarations()[0].getParentDecl(); + if (allSignaturesParentDecl !== signatureParentDecl) { + continue; + } + + if (this.signaturesAreIdenticalWithNewEnclosingTypes(allSignatures[i], signature, context, false)) { + if (!this.signatureReturnTypesAreIdentical(allSignatures[i], signature, context)) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overloads_cannot_differ_only_by_return_type)); } else if (funcDecl.kind() === 137 /* ConstructorDeclaration */) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_constructor_overload_signature)); @@ -47948,17 +49320,17 @@ var TypeScript; continue; } - if (this.signatureIsSubtypeOfTarget(signature, allSignatures[i], null, context)) { + if (this.signatureIsAssignableToTarget(signature, allSignatures[i], null, context)) { foundSubtypeSignature = true; break; } } if (!foundSubtypeSignature) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Specialized_overload_signature_is_not_subtype_of_any_non_specialized_signature)); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature)); } } - } else if (definitionSignature && definitionSignature != signature) { + } else if (definitionSignature && definitionSignature !== signature) { var comparisonInfo = new TypeComparisonInfo(); if (!definitionSignature.isResolved) { @@ -47982,16 +49354,16 @@ var TypeScript; signatureForVisibilityCheck = allSignatures[0]; } - if (funcDecl.kind() !== 137 /* ConstructorDeclaration */ && functionDeclaration.kind !== 2097152 /* ConstructSignature */ && signatureForVisibilityCheck && signature != signatureForVisibilityCheck) { + if (funcDecl.kind() !== 137 /* ConstructorDeclaration */ && functionDeclaration.kind !== 2097152 /* ConstructSignature */ && signatureForVisibilityCheck && signature !== signatureForVisibilityCheck) { var errorCode; - if (signatureForVisibilityCheck.anyDeclHasFlag(2 /* Private */) != signature.anyDeclHasFlag(2 /* Private */)) { + if (signatureForVisibilityCheck.anyDeclHasFlag(2 /* Private */) !== signature.anyDeclHasFlag(2 /* Private */)) { errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_public_or_private; - } else if (signatureForVisibilityCheck.anyDeclHasFlag(1 /* Exported */) != signature.anyDeclHasFlag(1 /* Exported */)) { + } else if (signatureForVisibilityCheck.anyDeclHasFlag(1 /* Exported */) !== signature.anyDeclHasFlag(1 /* Exported */)) { errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_exported_or_not_exported; - } else if (signatureForVisibilityCheck.anyDeclHasFlag(8 /* Ambient */) != signature.anyDeclHasFlag(8 /* Ambient */)) { + } else if (signatureForVisibilityCheck.anyDeclHasFlag(8 /* Ambient */) !== signature.anyDeclHasFlag(8 /* Ambient */)) { errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_ambient_or_non_ambient; - } else if (signatureForVisibilityCheck.anyDeclHasFlag(128 /* Optional */) != signature.anyDeclHasFlag(128 /* Optional */)) { + } else if (signatureForVisibilityCheck.anyDeclHasFlag(128 /* Optional */) !== signature.anyDeclHasFlag(128 /* Optional */)) { errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_optional_or_required; } @@ -48045,7 +49417,7 @@ var TypeScript; this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), privacyErrorReporter); this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), privacyErrorReporter); this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), privacyErrorReporter); - } else if (typeSymbol.kind == 8192 /* TypeParameter */) { + } else if (typeSymbol.kind === 8192 /* TypeParameter */) { this.checkSymbolPrivacy(declSymbol, typeSymbol.getConstraint(), privacyErrorReporter); } @@ -48059,27 +49431,27 @@ var TypeScript; if (declSymbol.isExternallyVisible()) { var symbolIsVisible = symbol.isExternallyVisible(); - if (symbolIsVisible && symbol.kind != 8192 /* TypeParameter */) { + if (symbolIsVisible && symbol.kind !== 8192 /* TypeParameter */) { var symbolPath = symbol.pathToRoot(); var declSymbolPath = declSymbol.pathToRoot(); - if (symbolPath[symbolPath.length - 1].kind === 32 /* DynamicModule */ && declSymbolPath[declSymbolPath.length - 1].kind == 32 /* DynamicModule */ && declSymbolPath[declSymbolPath.length - 1] != symbolPath[symbolPath.length - 1]) { + if (symbolPath[symbolPath.length - 1].kind === 32 /* DynamicModule */ && declSymbolPath[declSymbolPath.length - 1].kind === 32 /* DynamicModule */ && declSymbolPath[declSymbolPath.length - 1] !== symbolPath[symbolPath.length - 1]) { symbolIsVisible = false; var declSymbolScope = declSymbolPath[declSymbolPath.length - 1]; for (var i = symbolPath.length - 1; i >= 0; i--) { var aliasSymbols = symbolPath[i].getExternalAliasedSymbols(declSymbolScope); if (aliasSymbols) { symbolIsVisible = true; - aliasSymbols[0].setTypeUsedExternally(true); + aliasSymbols[0].setTypeUsedExternally(); break; } } symbol = symbolPath[symbolPath.length - 1]; } - } else if (symbol.kind == 128 /* TypeAlias */) { + } else if (symbol.kind === 128 /* TypeAlias */) { var aliasSymbol = symbol; symbolIsVisible = true; - aliasSymbol.setTypeUsedExternally(true); + aliasSymbol.setTypeUsedExternally(); } if (!symbolIsVisible) { @@ -48111,7 +49483,7 @@ var TypeScript; } }; - PullTypeResolver.prototype.typeParameterOfTypeDeclarationPrivacyErrorReporter = function (classOrInterface, indexOfTypeParameter, typeParameter, symbol, context) { + PullTypeResolver.prototype.typeParameterOfTypeDeclarationPrivacyErrorReporter = function (classOrInterface, typeParameterAST, typeParameter, symbol, context) { var decl = this.semanticInfoChain.getDeclForAST(classOrInterface); var enclosingDecl = this.getEnclosingDecl(decl); var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; @@ -48119,8 +49491,6 @@ var TypeScript; var typeParameters = classOrInterface.kind() === 131 /* ClassDeclaration */ ? classOrInterface.typeParameterList : classOrInterface.typeParameterList; - var typeParameterAST = typeParameters.typeParameters.nonSeparatorAt(indexOfTypeParameter); - var typeSymbol = symbol; var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { @@ -48254,7 +49624,7 @@ var TypeScript; if (functionSymbol && functionSymbol.isType() && !functionSymbol.isNamedTypeSymbol()) { return; } - } else if (functionSymbol.kind == 65536 /* Method */ && !isStatic && !functionSymbol.getContainer().isNamedTypeSymbol()) { + } else if (functionSymbol.kind === 65536 /* Method */ && !isStatic && !functionSymbol.getContainer().isNamedTypeSymbol()) { return; } functionSignature = functionDecl.getSignatureSymbol(); @@ -48659,7 +50029,7 @@ var TypeScript; }; PullTypeResolver.prototype.typeCheckMembersAgainstIndexer = function (containerType, containerTypeDecl, context) { - var indexSignatures = this.getBothKindsOfIndexSignatures(containerType, context); + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(containerType, context); var stringSignature = indexSignatures.stringSignature; var numberSignature = indexSignatures.numericSignature; @@ -48672,7 +50042,7 @@ var TypeScript; var relevantSignature = this.determineRelevantIndexerForMember(memberSymbol, numberSignature, stringSignature); if (relevantSignature) { var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsSubtypeOfTarget(memberSymbol.type, relevantSignature.returnType, member.ast(), context, comparisonInfo)) { + if (!this.sourceIsAssignableToTarget(memberSymbol.type, relevantSignature.returnType, member.ast(), context, comparisonInfo)) { this.reportErrorThatMemberIsNotSubtypeOfIndexer(memberSymbol, relevantSignature, member.ast(), context, comparisonInfo); } } @@ -48695,15 +50065,15 @@ var TypeScript; var enclosingSymbol = this.getEnclosingSymbolForAST(astForError); if (indexSignature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol) { if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type_0_NL_1, [indexSignature.returnType.toString(enclosingSymbol), comparisonInfo.message])); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_numerically_named_properties_must_be_assignable_to_numeric_indexer_type_0_NL_1, [indexSignature.returnType.toString(enclosingSymbol), comparisonInfo.message])); } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_numerically_named_properties_must_be_assignable_to_numeric_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); } } else { if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_named_properties_must_be_subtypes_of_string_indexer_type_0_NL_1, [indexSignature.returnType.toString(enclosingSymbol), comparisonInfo.message])); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_named_properties_must_be_assignable_to_string_indexer_type_0_NL_1, [indexSignature.returnType.toString(enclosingSymbol), comparisonInfo.message])); } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_named_properties_must_be_subtypes_of_string_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_named_properties_must_be_assignable_to_string_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); } } }; @@ -48756,7 +50126,7 @@ var TypeScript; foundError1 = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, enclosingDecl, comparisonInfo); if (!foundError1) { - foundError2 = !this.sourcePropertyIsSubtypeOfTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, classOrInterface, context, comparisonInfo); + foundError2 = !this.sourcePropertyIsAssignableToTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, classOrInterface, context, comparisonInfo); } if (foundError1 || foundError2) { @@ -48767,15 +50137,15 @@ var TypeScript; } if (!foundError && typeSymbol.hasOwnCallSignatures()) { - foundError = !this.sourceCallSignaturesAreSubtypeOfTargetCallSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); } if (!foundError && typeSymbol.hasOwnConstructSignatures()) { - foundError = !this.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); } if (!foundError && typeSymbol.hasOwnIndexSignatures()) { - foundError = !this.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); } if (!foundError && typeSymbol.isClass()) { @@ -48793,17 +50163,7 @@ var TypeScript; this.resolveDeclaredSymbol(extendedConstructorTypeProp, context); } - var typeConstructorTypePropType = typeConstructorTypeMembers[i].type; - var extendedConstructorTypePropType = extendedConstructorTypeProp.type; - if (!this.sourceIsSubtypeOfTarget(typeConstructorTypePropType, extendedConstructorTypePropType, classOrInterface, context, comparisonInfoForPropTypeCheck)) { - var propMessage; - var enclosingSymbol = this.getEnclosingSymbolForAST(classOrInterface); - if (comparisonInfoForPropTypeCheck.message) { - propMessage = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_static_property_0_of_class_1_and_class_2_are_incompatible_NL_3, [extendedConstructorTypeProp.getScopedNameEx().toString(), typeSymbol.toString(enclosingSymbol), extendedType.toString(enclosingSymbol), comparisonInfoForPropTypeCheck.message]); - } else { - propMessage = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_static_property_0_of_class_1_and_class_2_are_incompatible, [extendedConstructorTypeProp.getScopedNameEx().toString(), typeSymbol.toString(enclosingSymbol), extendedType.toString(enclosingSymbol)]); - } - comparisonInfo.addMessage(propMessage); + if (!this.sourcePropertyIsAssignableToTargetProperty(typeConstructorType, extendedConstructorType, typeConstructorTypeMembers[i], extendedConstructorTypeProp, classOrInterface, context, comparisonInfo)) { foundError = true; break; } @@ -48830,13 +50190,13 @@ var TypeScript; PullTypeResolver.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, enclosingDecl, context) { var comparisonInfo = new TypeComparisonInfo(); - var foundError = !this.sourceMembersAreSubtypeOfTargetMembers(classSymbol, implementedType, classDecl, context, comparisonInfo); + var foundError = !this.sourceMembersAreAssignableToTargetMembers(classSymbol, implementedType, classDecl, context, comparisonInfo); if (!foundError) { - foundError = !this.sourceCallSignaturesAreSubtypeOfTargetCallSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); if (!foundError) { - foundError = !this.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); if (!foundError) { - foundError = !this.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); } } } @@ -48847,15 +50207,39 @@ var TypeScript; } }; - PullTypeResolver.prototype.hasClassTypeSymbolConflictAsValue = function (valueDeclAST, typeSymbol, enclosingDecl, context) { + PullTypeResolver.prototype.computeValueSymbolFromAST = function (valueDeclAST, context) { + var prevInTypeCheck = context.inTypeCheck; + context.inTypeCheck = false; + var typeSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); - var valueSymbol = this.computeNameExpression(valueDeclAST, context, false); + + if (valueDeclAST.kind() == 11 /* IdentifierName */) { + var valueSymbol = this.computeNameExpression(valueDeclAST, context); + } else { + TypeScript.Debug.assert(valueDeclAST.kind() == 121 /* QualifiedName */); + var qualifiedName = valueDeclAST; + + var lhs = this.computeValueSymbolFromAST(qualifiedName.left, context); + var valueSymbol = this.computeDottedNameExpressionFromLHS(lhs.symbol, qualifiedName.left, qualifiedName.right, context, false); + } var valueSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); this.semanticInfoChain.setAliasSymbolForAST(valueDeclAST, typeSymbolAlias); + context.inTypeCheck = prevInTypeCheck; + + return { symbol: valueSymbol, alias: valueSymbolAlias }; + }; + + PullTypeResolver.prototype.hasClassTypeSymbolConflictAsValue = function (baseDeclAST, typeSymbol, enclosingDecl, context) { + var typeSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(baseDeclAST); + + var valueDeclAST = baseDeclAST.kind() == 126 /* GenericType */ ? baseDeclAST.name : baseDeclAST; + var valueSymbolInfo = this.computeValueSymbolFromAST(valueDeclAST, context); + var valueSymbol = valueSymbolInfo.symbol; + var valueSymbolAlias = valueSymbolInfo.alias; if (typeSymbolAlias && valueSymbolAlias) { - return typeSymbolAlias != valueSymbolAlias; + return typeSymbolAlias !== valueSymbolAlias; } if (!valueSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */)) { @@ -48865,7 +50249,7 @@ var TypeScript; var associatedContainerType = valueSymbol.type ? valueSymbol.type.getAssociatedContainerType() : null; if (associatedContainerType) { - return associatedContainerType != typeSymbol.getRootSymbol(); + return associatedContainerType !== typeSymbol.getRootSymbol(); } return true; @@ -48896,9 +50280,9 @@ var TypeScript; } } return; - } else if (typeDeclIsClass && isExtendedType && baseDeclAST.kind() == 11 /* IdentifierName */) { + } else if (typeDeclIsClass && isExtendedType) { if (this.hasClassTypeSymbolConflictAsValue(baseDeclAST, baseType, enclosingDecl, context)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.Type_reference_0_in_extends_clause_does_not_reference_constructor_function_for_1, [baseDeclAST.text(), baseType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_1, [TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(baseDeclAST.kind() == 126 /* GenericType */ ? baseDeclAST.name : baseDeclAST), baseType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); } } @@ -48911,11 +50295,15 @@ var TypeScript; } if (isExtendedType) { - this.typeCheckIfTypeExtendsType(classOrInterface, name, typeSymbol, baseType, enclosingDecl, context); + this.typeCheckCallBacks.push(function (context) { + return _this.typeCheckIfTypeExtendsType(classOrInterface, name, typeSymbol, baseType, enclosingDecl, context); + }); } else { TypeScript.Debug.assert(classOrInterface.kind() === 131 /* ClassDeclaration */); - this.typeCheckIfClassImplementsType(classOrInterface, typeSymbol, baseType, enclosingDecl, context); + this.typeCheckCallBacks.push(function (context) { + return _this.typeCheckIfClassImplementsType(classOrInterface, typeSymbol, baseType, enclosingDecl, context); + }); } this.checkSymbolPrivacy(typeSymbol, baseType, function (errorSymbol) { @@ -48925,14 +50313,12 @@ var TypeScript; PullTypeResolver.prototype.typeCheckBases = function (classOrInterface, name, heritageClauses, typeSymbol, enclosingDecl, context) { var _this = this; - var extendsClause = TypeScript.getExtendsHeritageClause(heritageClauses); - var implementsClause = TypeScript.getImplementsHeritageClause(heritageClauses); + var extendsClause = TypeScript.ASTHelpers.getExtendsHeritageClause(heritageClauses); + var implementsClause = TypeScript.ASTHelpers.getImplementsHeritageClause(heritageClauses); if (!extendsClause && !implementsClause) { return; } - var typeDeclIsClass = classOrInterface.kind() === 131 /* ClassDeclaration */; - if (extendsClause) { for (var i = 0; i < extendsClause.typeNames.nonSeparatorCount(); i++) { this.typeCheckBase(classOrInterface, name, typeSymbol, extendsClause.typeNames.nonSeparatorAt(i), true, enclosingDecl, context); @@ -48978,7 +50364,7 @@ var TypeScript; } var baseTypes = typeSymbol.getExtendedTypes(); for (var i = 0; i < baseTypes.length; i++) { - if (this.checkNamedPropertyTypeIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedMembersMap, context) || this.checkIndexSignatureIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedIndexSignatures, typeHasOwnNumberIndexer, typeHasOwnStringIndexer, context)) { + if (this.checkNamedPropertyIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedMembersMap, context) || this.checkIndexSignatureIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedIndexSignatures, typeHasOwnNumberIndexer, typeHasOwnStringIndexer, context)) { return; } } @@ -48990,7 +50376,7 @@ var TypeScript; this.checkInheritedMembersAgainstInheritedIndexSignatures(name, typeSymbol, inheritedIndexSignatures, inheritedMembersMap, context); }; - PullTypeResolver.prototype.checkNamedPropertyTypeIdentityBetweenBases = function (interfaceName, interfaceSymbol, baseTypeSymbol, inheritedMembersMap, context) { + PullTypeResolver.prototype.checkNamedPropertyIdentityBetweenBases = function (interfaceName, interfaceSymbol, baseTypeSymbol, inheritedMembersMap, context) { var baseMembers = baseTypeSymbol.getAllMembers(4096 /* Property */ | 65536 /* Method */, 0 /* all */); for (var i = 0; i < baseMembers.length; i++) { var member = baseMembers[i]; @@ -49000,10 +50386,12 @@ var TypeScript; continue; } + this.resolveDeclaredSymbol(member, context); + if (inheritedMembersMap[memberName]) { var prevMember = inheritedMembersMap[memberName]; - if (prevMember.baseOrigin !== baseTypeSymbol && !this.typesAreIdentical(member.type, prevMember.memberSymbol.type)) { - var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_property_0_of_types_1_and_2_are_not_identical, [memberName, prevMember.baseOrigin.getScopedName(), baseTypeSymbol.getScopedName()]); + if (prevMember.baseOrigin !== baseTypeSymbol && !this.propertiesAreIdenticalWithNewEnclosingTypes(baseTypeSymbol, prevMember.baseOrigin, member, prevMember.memberSymbol, context)) { + var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Named_properties_0_of_types_1_and_2_are_not_identical, [memberName, prevMember.baseOrigin.getScopedName(), baseTypeSymbol.getScopedName()]); context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(interfaceName, TypeScript.DiagnosticCode.Interface_0_cannot_simultaneously_extend_types_1_and_2_NL_3, [interfaceSymbol.getDisplayName(), prevMember.baseOrigin.getScopedName(), baseTypeSymbol.getScopedName(), innerDiagnostic])); return true; } @@ -49025,14 +50413,15 @@ var TypeScript; var currentInheritedSignature = indexSignaturesFromThisBaseType[i]; var parameterTypeIsString = currentInheritedSignature.parameters[0].type === this.semanticInfoChain.stringTypeSymbol; - var parameterTypeIsNumber = !parameterTypeIsString; + var parameterTypeIsNumber = currentInheritedSignature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol; + if (parameterTypeIsString && derivedTypeHasOwnStringSignature || parameterTypeIsNumber && derivedTypeHasOwnNumberSignature) { continue; } if (parameterTypeIsString) { if (allInheritedSignatures.stringSignatureWithBaseOrigin) { - if (allInheritedSignatures.stringSignatureWithBaseOrigin.baseOrigin !== baseTypeSymbol && !this.typesAreIdentical(allInheritedSignatures.stringSignatureWithBaseOrigin.signature.returnType, currentInheritedSignature.returnType)) { + if (allInheritedSignatures.stringSignatureWithBaseOrigin.baseOrigin !== baseTypeSymbol && !this.typesAreIdentical(allInheritedSignatures.stringSignatureWithBaseOrigin.signature.returnType, currentInheritedSignature.returnType, context)) { var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_string_indexer_of_types_0_and_1_are_not_identical, [allInheritedSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(), baseTypeSymbol.getScopedName()]); context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(interfaceName, TypeScript.DiagnosticCode.Interface_0_cannot_simultaneously_extend_types_1_and_2_NL_3, [interfaceSymbol.getDisplayName(), allInheritedSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(), baseTypeSymbol.getScopedName(), innerDiagnostic])); return true; @@ -49042,7 +50431,7 @@ var TypeScript; } } else if (parameterTypeIsNumber) { if (allInheritedSignatures.numberSignatureWithBaseOrigin) { - if (allInheritedSignatures.numberSignatureWithBaseOrigin.baseOrigin !== baseTypeSymbol && !this.typesAreIdentical(allInheritedSignatures.numberSignatureWithBaseOrigin.signature.returnType, currentInheritedSignature.returnType)) { + if (allInheritedSignatures.numberSignatureWithBaseOrigin.baseOrigin !== baseTypeSymbol && !this.typesAreIdentical(allInheritedSignatures.numberSignatureWithBaseOrigin.signature.returnType, currentInheritedSignature.returnType, context)) { var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_number_indexer_of_types_0_and_1_are_not_identical, [allInheritedSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(), baseTypeSymbol.getScopedName()]); context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(interfaceName, TypeScript.DiagnosticCode.Interface_0_cannot_simultaneously_extend_types_1_and_2_NL_3, [interfaceSymbol.getDisplayName(), allInheritedSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(), baseTypeSymbol.getScopedName(), innerDiagnostic])); return true; @@ -49082,16 +50471,16 @@ var TypeScript; continue; } - var memberIsSubtype = this.sourceIsSubtypeOfTarget(memberWithBaseOrigin.memberSymbol.type, relevantSignature.returnType, interfaceName, context, comparisonInfo); + var memberIsSubtype = this.sourceIsAssignableToTarget(memberWithBaseOrigin.memberSymbol.type, relevantSignature.returnType, interfaceName, context, comparisonInfo); if (!memberIsSubtype) { var enclosingSymbol = this.getEnclosingSymbolForAST(interfaceName); if (relevantSignatureIsNumberSignature) { - var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_of_property_0_in_type_1_is_not_a_subtype_of_number_indexer_type_in_type_2_NL_3, [memberName, memberWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), comparisonInfo.message]); + var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_of_property_0_in_type_1_is_not_assignable_to_number_indexer_type_in_type_2_NL_3, [memberName, memberWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), comparisonInfo.message]); context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(interfaceName, TypeScript.DiagnosticCode.Interface_0_cannot_simultaneously_extend_types_1_and_2_NL_3, [interfaceSymbol.getDisplayName(enclosingSymbol), memberWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), innerDiagnostic])); } else { - var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_of_property_0_in_type_1_is_not_a_subtype_of_string_indexer_type_in_type_2_NL_3, [memberName, memberWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), comparisonInfo.message]); + var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_of_property_0_in_type_1_is_not_assignable_to_string_indexer_type_in_type_2_NL_3, [memberName, memberWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), comparisonInfo.message]); context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(interfaceName, TypeScript.DiagnosticCode.Interface_0_cannot_simultaneously_extend_types_1_and_2_NL_3, [interfaceSymbol.getDisplayName(enclosingSymbol), memberWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), innerDiagnostic])); } @@ -49109,11 +50498,11 @@ var TypeScript; } var comparisonInfo = new TypeComparisonInfo(); - var signatureIsSubtype = this.sourceIsSubtypeOfTarget(inheritedIndexSignatures.numberSignatureWithBaseOrigin.signature.returnType, inheritedIndexSignatures.stringSignatureWithBaseOrigin.signature.returnType, interfaceName, context, comparisonInfo); + var signatureIsSubtype = this.sourceIsAssignableToTarget(inheritedIndexSignatures.numberSignatureWithBaseOrigin.signature.returnType, inheritedIndexSignatures.stringSignatureWithBaseOrigin.signature.returnType, interfaceName, context, comparisonInfo); if (!signatureIsSubtype) { var enclosingSymbol = this.getEnclosingSymbolForAST(interfaceName); - var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_of_number_indexer_in_type_0_is_not_a_subtype_of_string_indexer_type_in_type_1_NL_2, [ + var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_of_number_indexer_in_type_0_is_not_assignable_to_string_indexer_type_in_type_1_NL_2, [ inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), comparisonInfo.message]); context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(interfaceName, TypeScript.DiagnosticCode.Interface_0_cannot_simultaneously_extend_types_1_and_2_NL_3, [ @@ -49159,7 +50548,7 @@ var TypeScript; return false; } - if (astSymbol.kind === 32768 /* ConstructorMethod */) { + if (astSymbol.kind === 32768 /* ConstructorMethod */ || astSymbol.kind === 16384 /* Function */) { return false; } } @@ -49216,8 +50605,7 @@ var TypeScript; return false; }; - PullTypeResolver.prototype.instantiateType = function (type, typeParameterArgumentMap, instantiateFunctionTypeParameters) { - if (typeof instantiateFunctionTypeParameters === "undefined") { instantiateFunctionTypeParameters = false; } + PullTypeResolver.prototype.instantiateType = function (type, typeParameterArgumentMap) { if (type.isPrimitive()) { return type; } @@ -49230,48 +50618,63 @@ var TypeScript; return typeParameterArgumentMap[type.pullSymbolID]; } - if (type.isTypeParameter() && type.isFunctionTypeParameter()) { - return type; + type._resolveDeclaredSymbol(); + if (type.isTypeParameter()) { + return this.instantiateTypeParameter(type, typeParameterArgumentMap); } - type._resolveDeclaredSymbol(); if (type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap, instantiateFunctionTypeParameters); + return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); } return type; }; - PullTypeResolver.prototype.instantiateSignature = function (signature, typeParameterArgumentMap, instantiateFunctionTypeParameters) { - if (typeof instantiateFunctionTypeParameters === "undefined") { instantiateFunctionTypeParameters = false; } + PullTypeResolver.prototype.instantiateTypeParameter = function (typeParameter, typeParameterArgumentMap) { + var constraint = typeParameter.getConstraint(); + if (!constraint) { + return typeParameter; + } + + var instantiatedConstraint = this.instantiateType(constraint, typeParameterArgumentMap); + + if (instantiatedConstraint == constraint) { + return typeParameter; + } + + var rootTypeParameter = typeParameter.getRootSymbol(); + var instantiation = rootTypeParameter.getSpecialization([instantiatedConstraint]); + if (instantiation) { + return instantiation; + } + + instantiation = new TypeScript.PullInstantiatedTypeParameterSymbol(rootTypeParameter, instantiatedConstraint); + return instantiation; + }; + + PullTypeResolver.prototype.instantiateSignature = function (signature, typeParameterArgumentMap) { if (!signature.wrapsSomeTypeParameter(typeParameterArgumentMap)) { return signature; } - var typeArguments = []; + var rootSignature = signature.getRootSymbol(); + var mutableTypeParameterMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(typeParameterArgumentMap); + TypeScript.PullInstantiationHelpers.instantiateTypeArgument(this, signature, mutableTypeParameterMap); - TypeScript.nSpecializedSignaturesCreated++; - - var instantiatedSignature = new TypeScript.PullSignatureSymbol(signature.kind); - instantiatedSignature.setRootSymbol(signature); - - var typeParameters = signature.getTypeParameters(); - var constraint = null; - var typeParameter = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = typeParameters[i]; - - instantiatedSignature.addTypeParameter(typeParameter); + var instantiatedSignature = rootSignature.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); + if (instantiatedSignature) { + return instantiatedSignature; } - instantiatedSignature.returnType = this.instantiateType((signature.returnType || this.semanticInfoChain.anyTypeSymbol), typeParameterArgumentMap, instantiateFunctionTypeParameters); + TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(signature, mutableTypeParameterMap); + typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; - if (instantiateFunctionTypeParameters) { - instantiatedSignature.functionType = this.instantiateType(signature.functionType, typeParameterArgumentMap, instantiateFunctionTypeParameters); - } + instantiatedSignature = new TypeScript.PullInstantiatedSignatureSymbol(rootSignature, typeParameterArgumentMap); - var parameters = signature.parameters; + instantiatedSignature.returnType = this.instantiateType((rootSignature.returnType || this.semanticInfoChain.anyTypeSymbol), typeParameterArgumentMap); + instantiatedSignature.functionType = this.instantiateType(rootSignature.functionType, typeParameterArgumentMap); + + var parameters = rootSignature.parameters; var parameter = null; if (parameters) { @@ -49288,7 +50691,7 @@ var TypeScript; } instantiatedSignature.addParameter(parameter, parameter.isOptional); - parameter.type = this.instantiateType(parameters[j].type, typeParameterArgumentMap, instantiateFunctionTypeParameters); + parameter.type = this.instantiateType(parameters[j].type, typeParameterArgumentMap); } } @@ -49300,7 +50703,7 @@ var TypeScript; TypeScript.PullTypeResolver = PullTypeResolver; var TypeComparisonInfo = (function () { - function TypeComparisonInfo(sourceComparisonInfo) { + function TypeComparisonInfo(sourceComparisonInfo, useSameIndent) { this.onlyCaptureFirstError = false; this.flags = 0 /* SuccessfulComparison */; this.message = ""; @@ -49310,7 +50713,10 @@ var TypeScript; this.flags = sourceComparisonInfo.flags; this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; this.stringConstantVal = sourceComparisonInfo.stringConstantVal; - this.indent = sourceComparisonInfo.indent + 1; + this.indent = sourceComparisonInfo.indent; + if (!useSameIndent) { + this.indent++; + } } } TypeComparisonInfo.prototype.indentString = function () { @@ -49441,25 +50847,24 @@ var TypeScript; this._resolver = null; this._topLevelDecls = null; this._fileNames = null; - var span = new TypeScript.TextSpan(0, 0); - var globalDecl = new TypeScript.RootPullDecl("", "", 0 /* Global */, 0 /* None */, span, this, false); + var globalDecl = new TypeScript.RootPullDecl("", "", 0 /* Global */, 0 /* None */, this, false); this.documents[0] = new TypeScript.Document(this.compiler, this, "", [], null, 0 /* None */, 0, false, null, globalDecl); - this.anyTypeDecl = new TypeScript.NormalPullDecl("any", "any", 2 /* Primitive */, 0 /* None */, globalDecl, span); - this.booleanTypeDecl = new TypeScript.NormalPullDecl("boolean", "boolean", 2 /* Primitive */, 0 /* None */, globalDecl, span); - this.numberTypeDecl = new TypeScript.NormalPullDecl("number", "number", 2 /* Primitive */, 0 /* None */, globalDecl, span); - this.stringTypeDecl = new TypeScript.NormalPullDecl("string", "string", 2 /* Primitive */, 0 /* None */, globalDecl, span); - this.voidTypeDecl = new TypeScript.NormalPullDecl("void", "void", 2 /* Primitive */, 0 /* None */, globalDecl, span); + this.anyTypeDecl = new TypeScript.NormalPullDecl("any", "any", 2 /* Primitive */, 0 /* None */, globalDecl); + this.booleanTypeDecl = new TypeScript.NormalPullDecl("boolean", "boolean", 2 /* Primitive */, 0 /* None */, globalDecl); + this.numberTypeDecl = new TypeScript.NormalPullDecl("number", "number", 2 /* Primitive */, 0 /* None */, globalDecl); + this.stringTypeDecl = new TypeScript.NormalPullDecl("string", "string", 2 /* Primitive */, 0 /* None */, globalDecl); + this.voidTypeDecl = new TypeScript.NormalPullDecl("void", "void", 2 /* Primitive */, 0 /* None */, globalDecl); - this.nullTypeDecl = new TypeScript.RootPullDecl("null", "", 2 /* Primitive */, 0 /* None */, span, this, false); - this.undefinedTypeDecl = new TypeScript.RootPullDecl("undefined", "", 2 /* Primitive */, 0 /* None */, span, this, false); - this.undefinedValueDecl = new TypeScript.NormalPullDecl("undefined", "undefined", 512 /* Variable */, 8 /* Ambient */, globalDecl, span); + this.nullTypeDecl = new TypeScript.RootPullDecl("null", "", 2 /* Primitive */, 0 /* None */, this, false); + this.undefinedTypeDecl = new TypeScript.RootPullDecl("undefined", "", 2 /* Primitive */, 0 /* None */, this, false); + this.undefinedValueDecl = new TypeScript.NormalPullDecl("undefined", "undefined", 512 /* Variable */, 8 /* Ambient */, globalDecl); this.invalidate(); } SemanticInfoChain.prototype.getDocument = function (fileName) { var document = this.fileNameToDocument[fileName]; - return document ? document : null; + return document || null; }; SemanticInfoChain.prototype.lineMap = function (fileName) { @@ -49505,8 +50910,7 @@ var TypeScript; this.undefinedTypeSymbol = this.addPrimitiveTypeSymbol(this.undefinedTypeDecl); this.undefinedValueSymbol = this.addPrimitiveValueSymbol(this.undefinedValueDecl, this.undefinedTypeSymbol); - var span = new TypeScript.TextSpan(0, 0); - var emptyTypeDecl = new TypeScript.PullSynthesizedDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, null, span, this); + var emptyTypeDecl = new TypeScript.PullSynthesizedDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, null, this); var emptyTypeSymbol = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); emptyTypeDecl.setSymbol(emptyTypeSymbol); emptyTypeSymbol.addDeclaration(emptyTypeDecl); @@ -49567,7 +50971,7 @@ var TypeScript; break; } - if (doNotGoPastThisDecl && topLevelDecl.name == doNotGoPastThisDecl.fileName()) { + if (doNotGoPastThisDecl && topLevelDecl.name === doNotGoPastThisDecl.fileName()) { return null; } } @@ -49604,13 +51008,6 @@ var TypeScript; SemanticInfoChain.prototype.findExternalModule = function (id) { id = TypeScript.normalizePath(id); - var dtsFile = id + ".d.ts"; - var dtsCacheID = this.getDeclPathCacheID([dtsFile], 32 /* DynamicModule */); - var symbol = this.symbolCache[dtsCacheID]; - if (symbol) { - return symbol; - } - var tsFile = id + ".ts"; var tsCacheID = this.getDeclPathCacheID([tsFile], 32 /* DynamicModule */); symbol = this.symbolCache[tsCacheID]; @@ -49618,27 +51015,44 @@ var TypeScript; return symbol; } - symbol = null; + var dtsFile = id + ".d.ts"; + var dtsCacheID = this.getDeclPathCacheID([dtsFile], 32 /* DynamicModule */); + var symbol = this.symbolCache[dtsCacheID]; + if (symbol) { + return symbol; + } + + var dtsSymbol; for (var i = 0; i < this.documents.length; i++) { var document = this.documents[i]; var topLevelDecl = document.topLevelDecl(); if (topLevelDecl.isExternalModule()) { - var isDtsFile = document.fileName == dtsFile; - if (isDtsFile || document.fileName == tsFile) { + var isTsFile = document.fileName === tsFile; + if (isTsFile || document.fileName === dtsFile) { var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; symbol = dynamicModuleDecl.getSymbol(); - this.symbolCache[dtsCacheID] = isDtsFile ? symbol : null; - this.symbolCache[tsCacheID] = !TypeScript.isDTSFile ? symbol : null; - return symbol; + + if (isTsFile) { + this.symbolCache[tsCacheID] = symbol; + + return symbol; + } else { + dtsSymbol = symbol; + } } } } + if (dtsSymbol) { + this.symbolCache[dtsCacheID] = symbol; + return dtsSymbol; + } + this.symbolCache[dtsCacheID] = null; this.symbolCache[tsCacheID] = null; - return symbol; + return null; }; SemanticInfoChain.prototype.findAmbientExternalModuleInGlobalContext = function (id) { @@ -49685,25 +51099,21 @@ var TypeScript; var decls = TypeScript.sentinelEmptyArray; var path; var foundDecls = TypeScript.sentinelEmptyArray; - var keepSearching = (declKind & 164 /* SomeContainer */) || (declKind & 16 /* Interface */); for (var i = 0; i < declPath.length; i++) { path = declPath[i]; decls = TypeScript.sentinelEmptyArray; + var kind = (i === declPath.length - 1) ? declKind : 164 /* SomeContainer */; for (var j = 0; j < declsToSearch.length; j++) { - foundDecls = declsToSearch[j].searchChildDecls(path, declKind); + foundDecls = declsToSearch[j].searchChildDecls(path, kind); for (var k = 0; k < foundDecls.length; k++) { - if (decls == TypeScript.sentinelEmptyArray) { + if (decls === TypeScript.sentinelEmptyArray) { decls = []; } decls[decls.length] = foundDecls[k]; } - - if (foundDecls.length && !keepSearching) { - break; - } } declsToSearch = decls; @@ -49752,9 +51162,20 @@ var TypeScript; var symbol = null; if (decls.length) { - symbol = decls[0].getSymbol(); + var decl = decls[0]; + if (TypeScript.hasFlag(decl.kind, 164 /* SomeContainer */)) { + var valueDecl = decl.getValueDecl(); + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + } + symbol = decl.getSymbol(); if (symbol) { + for (var i = 1; i < decls.length; i++) { + decls[i].ensureSymbolIsBound(); + } + this.symbolCache[cacheID] = symbol; } } @@ -49806,7 +51227,6 @@ var TypeScript; } TypeScript.pullSymbolID = 0; - TypeScript.globalTyvarID = 0; this.resetGlobalSymbols(); @@ -49814,7 +51234,7 @@ var TypeScript; }; SemanticInfoChain.prototype.settingsChangeAffectsSyntax = function (before, after) { - return before.allowAutomaticSemicolonInsertion() !== after.allowAutomaticSemicolonInsertion() || before.codeGenTarget() !== after.codeGenTarget() || before.propagateEnumConstants() != after.propagateEnumConstants(); + return before.allowAutomaticSemicolonInsertion() !== after.allowAutomaticSemicolonInsertion() || before.codeGenTarget() !== after.codeGenTarget() || before.propagateEnumConstants() !== after.propagateEnumConstants(); }; SemanticInfoChain.prototype.setSymbolForAST = function (ast, symbol) { @@ -49822,7 +51242,7 @@ var TypeScript; }; SemanticInfoChain.prototype.getSymbolForAST = function (ast) { - return this.astSymbolMap[ast.syntaxID()]; + return this.astSymbolMap[ast.syntaxID()] || null; }; SemanticInfoChain.prototype.setAliasSymbolForAST = function (ast, symbol) { @@ -49872,7 +51292,7 @@ var TypeScript; SemanticInfoChain.prototype.getDiagnostics = function (fileName) { var diagnostics = this.fileNameToDiagnostics[fileName]; - return diagnostics ? diagnostics : []; + return diagnostics || []; }; SemanticInfoChain.prototype.getBinder = function () { @@ -49902,9 +51322,8 @@ var TypeScript; containingSymbol.addIndexSignature(indexSignature); - var span = TypeScript.TextSpan.fromBounds(ast.start(), ast.end()); - var indexSigDecl = new TypeScript.PullSynthesizedDecl("", "", 4194304 /* IndexSignature */, 2048 /* Signature */, containingDecl, span, containingDecl.semanticInfoChain()); - var indexParamDecl = new TypeScript.PullSynthesizedDecl(indexParamName, indexParamName, 2048 /* Parameter */, 0 /* None */, indexSigDecl, span, containingDecl.semanticInfoChain()); + var indexSigDecl = new TypeScript.PullSynthesizedDecl("", "", 4194304 /* IndexSignature */, 2048 /* Signature */, containingDecl, containingDecl.semanticInfoChain); + var indexParamDecl = new TypeScript.PullSynthesizedDecl(indexParamName, indexParamName, 2048 /* Parameter */, 0 /* None */, indexSigDecl, containingDecl.semanticInfoChain); indexSigDecl.setSignatureSymbol(indexSignature); indexParamDecl.setSymbol(indexParameterSymbol); indexSignature.addDeclaration(indexSigDecl); @@ -49961,14 +51380,28 @@ var TypeScript; return this._topLevelDecls; }; - SemanticInfoChain.prototype.addDiagnosticFromAST = function (ast, diagnosticKey, arguments) { - if (typeof arguments === "undefined") { arguments = null; } - this.addDiagnostic(this.diagnosticFromAST(ast, diagnosticKey, arguments)); + SemanticInfoChain.prototype.addDiagnosticFromAST = function (ast, diagnosticKey, _arguments, additionalLocations) { + if (typeof _arguments === "undefined") { _arguments = null; } + if (typeof additionalLocations === "undefined") { additionalLocations = null; } + this.addDiagnostic(this.diagnosticFromAST(ast, diagnosticKey, _arguments, additionalLocations)); }; - SemanticInfoChain.prototype.diagnosticFromAST = function (ast, diagnosticKey, arguments) { - if (typeof arguments === "undefined") { arguments = null; } - return new TypeScript.Diagnostic(ast.fileName(), this.lineMap(ast.fileName()), ast.start(), ast.width(), diagnosticKey, arguments); + SemanticInfoChain.prototype.diagnosticFromAST = function (ast, diagnosticKey, _arguments, additionalLocations) { + if (typeof _arguments === "undefined") { _arguments = null; } + if (typeof additionalLocations === "undefined") { additionalLocations = null; } + return new TypeScript.Diagnostic(ast.fileName(), this.lineMap(ast.fileName()), ast.start(), ast.width(), diagnosticKey, _arguments, additionalLocations); + }; + + SemanticInfoChain.prototype.locationFromAST = function (ast) { + return new TypeScript.Location(ast.fileName(), this.lineMap(ast.fileName()), ast.start(), ast.width()); + }; + + SemanticInfoChain.prototype.duplicateIdentifierDiagnosticFromAST = function (ast, identifier, additionalLocationAST) { + return this.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Duplicate_identifier_0, [identifier], additionalLocationAST ? [this.locationFromAST(additionalLocationAST)] : null); + }; + + SemanticInfoChain.prototype.addDuplicateIdentifierDiagnosticFromAST = function (ast, identifier, additionalLocationAST) { + this.addDiagnostic(this.duplicateIdentifierDiagnosticFromAST(ast, identifier, additionalLocationAST)); }; return SemanticInfoChain; })(); @@ -50039,7 +51472,6 @@ var TypeScript; function preCollectImportDecls(ast, context) { var importDecl = ast; var declFlags = 0 /* None */; - var span = TypeScript.TextSpan.fromBounds(importDecl.start(), importDecl.end()); var parent = context.getParent(); @@ -50047,19 +51479,17 @@ var TypeScript; declFlags |= 1 /* Exported */; } - var decl = new TypeScript.NormalPullDecl(importDecl.identifier.valueText(), importDecl.identifier.text(), 128 /* TypeAlias */, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(importDecl.identifier.valueText(), importDecl.identifier.text(), 128 /* TypeAlias */, declFlags, parent); context.semanticInfoChain.setDeclForAST(ast, decl); context.semanticInfoChain.setASTForDecl(decl, ast); } function preCollectScriptDecls(sourceUnit, context) { - var span = TypeScript.TextSpan.fromBounds(sourceUnit.start(), sourceUnit.end()); - var fileName = sourceUnit.fileName(); var isExternalModule = context.document.isExternalModule(); - var decl = new TypeScript.RootPullDecl(fileName, fileName, 1 /* Script */, 0 /* None */, span, context.semanticInfoChain, isExternalModule); + var decl = new TypeScript.RootPullDecl(fileName, fileName, 1 /* Script */, 0 /* None */, context.semanticInfoChain, isExternalModule); context.semanticInfoChain.setDeclForAST(sourceUnit, decl); context.semanticInfoChain.setASTForDecl(decl, sourceUnit); @@ -50075,10 +51505,9 @@ var TypeScript; var moduleContainsExecutableCode = containsExecutableCode(sourceUnit.moduleElements); var kind = 32 /* DynamicModule */; - var span = TypeScript.TextSpan.fromBounds(sourceUnit.start(), sourceUnit.end()); var valueText = TypeScript.quoteStr(fileName); - var decl = new TypeScript.NormalPullDecl(valueText, fileName, kind, declFlags, context.getParent(), span); + var decl = new TypeScript.NormalPullDecl(valueText, fileName, kind, declFlags, context.getParent()); context.semanticInfoChain.setASTForDecl(decl, sourceUnit); @@ -50095,7 +51524,6 @@ var TypeScript; function preCollectEnumDecls(enumDecl, context) { var declFlags = 0 /* None */; var enumName = enumDecl.identifier.valueText(); - var kind = 4 /* Container */; if ((TypeScript.hasModifier(enumDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(enumDecl, context)) && !containingModuleHasExportAssignment(enumDecl)) { declFlags |= 1 /* Exported */; @@ -50106,18 +51534,13 @@ var TypeScript; } declFlags |= 4096 /* Enum */; - kind = 64 /* Enum */; + var kind = 64 /* Enum */; - var span = TypeScript.TextSpan.fromBounds(enumDecl.start(), enumDecl.end()); - - var enumDeclaration = new TypeScript.NormalPullDecl(enumName, enumDecl.identifier.text(), kind, declFlags, context.getParent(), span); + var enumDeclaration = new TypeScript.NormalPullDecl(enumName, enumDecl.identifier.text(), kind, declFlags, context.getParent()); context.semanticInfoChain.setDeclForAST(enumDecl, enumDeclaration); context.semanticInfoChain.setASTForDecl(enumDeclaration, enumDecl); - var enumIndexerDecl = new TypeScript.NormalPullDecl("", "", 4194304 /* IndexSignature */, 2048 /* Signature */, enumDeclaration, span); - var enumIndexerParameter = new TypeScript.NormalPullDecl("x", "x", 2048 /* Parameter */, 0 /* None */, enumIndexerDecl, span); - - var valueDecl = new TypeScript.NormalPullDecl(enumDeclaration.name, enumDeclaration.getDisplayName(), 512 /* Variable */, enumDeclaration.flags, context.getParent(), enumDeclaration.getSpan()); + var valueDecl = new TypeScript.NormalPullDecl(enumDeclaration.name, enumDeclaration.getDisplayName(), 512 /* Variable */, enumDeclaration.flags, context.getParent()); enumDeclaration.setValueDecl(valueDecl); context.semanticInfoChain.setASTForDecl(valueDecl, enumDecl); @@ -50127,9 +51550,7 @@ var TypeScript; function createEnumElementDecls(propertyDecl, context) { var parent = context.getParent(); - var span = TypeScript.TextSpan.fromBounds(propertyDecl.start(), propertyDecl.end()); - - var decl = new TypeScript.PullEnumElementDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), parent, span); + var decl = new TypeScript.PullEnumElementDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), parent); context.semanticInfoChain.setDeclForAST(propertyDecl, decl); context.semanticInfoChain.setASTForDecl(decl, propertyDecl); } @@ -50151,13 +51572,11 @@ var TypeScript; var kind = isDynamic ? 32 /* DynamicModule */ : 4 /* Container */; - var span = TypeScript.TextSpan.fromBounds(moduleDecl.start(), moduleDecl.end()); - if (moduleDecl.stringLiteral) { var valueText = TypeScript.quoteStr(moduleDecl.stringLiteral.valueText()); var text = moduleDecl.stringLiteral.text(); - var decl = new TypeScript.NormalPullDecl(valueText, text, kind, declFlags, context.getParent(), span); + var decl = new TypeScript.NormalPullDecl(valueText, text, kind, declFlags, context.getParent()); context.semanticInfoChain.setDeclForAST(moduleDecl, decl); context.semanticInfoChain.setDeclForAST(moduleDecl.stringLiteral, decl); @@ -50178,7 +51597,7 @@ var TypeScript; specificFlags |= 1 /* Exported */; } - var decl = new TypeScript.NormalPullDecl(moduleName.valueText(), moduleName.text(), kind, specificFlags, context.getParent(), span); + var decl = new TypeScript.NormalPullDecl(moduleName.valueText(), moduleName.text(), kind, specificFlags, context.getParent()); context.semanticInfoChain.setDeclForAST(moduleDecl, decl); context.semanticInfoChain.setDeclForAST(moduleName, decl); @@ -50210,7 +51629,7 @@ var TypeScript; function createModuleVariableDecl(decl, moduleNameAST, context) { decl.setFlags(decl.flags | getInitializationFlag(decl)); - var valueDecl = new TypeScript.NormalPullDecl(decl.name, decl.getDisplayName(), 512 /* Variable */, decl.flags, context.getParent(), decl.getSpan()); + var valueDecl = new TypeScript.NormalPullDecl(decl.name, decl.getDisplayName(), 512 /* Variable */, decl.flags, context.getParent()); decl.setValueDecl(valueDecl); context.semanticInfoChain.setASTForDecl(valueDecl, moduleNameAST); } @@ -50225,7 +51644,11 @@ var TypeScript; if (containsExecutableCode(moduleDecl.moduleElements)) { return true; } - } else if (member.kind() !== 128 /* InterfaceDeclaration */ && member.kind() !== 133 /* ImportDeclaration */) { + } else if (member.kind() === 133 /* ImportDeclaration */) { + if (TypeScript.hasModifier(member.modifiers, 1 /* Exported */)) { + return true; + } + } else if (member.kind() !== 128 /* InterfaceDeclaration */) { return true; } } @@ -50235,7 +51658,6 @@ var TypeScript; function preCollectClassDecls(classDecl, context) { var declFlags = 0 /* None */; - var constructorDeclKind = 512 /* Variable */; if ((TypeScript.hasModifier(classDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(classDecl, context)) && !containingModuleHasExportAssignment(classDecl)) { declFlags |= 1 /* Exported */; @@ -50245,12 +51667,11 @@ var TypeScript; declFlags |= 8 /* Ambient */; } - var span = TypeScript.TextSpan.fromBounds(classDecl.start(), classDecl.end()); var parent = context.getParent(); - var decl = new TypeScript.NormalPullDecl(classDecl.identifier.valueText(), classDecl.identifier.text(), 8 /* Class */, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(classDecl.identifier.valueText(), classDecl.identifier.text(), 8 /* Class */, declFlags, parent); - var constructorDecl = new TypeScript.NormalPullDecl(classDecl.identifier.valueText(), classDecl.identifier.text(), constructorDeclKind, declFlags | 16384 /* ClassConstructorVariable */, parent, span); + var constructorDecl = new TypeScript.NormalPullDecl(classDecl.identifier.valueText(), classDecl.identifier.text(), 512 /* Variable */, declFlags | 16384 /* ClassConstructorVariable */, parent); decl.setValueDecl(constructorDecl); @@ -50268,15 +51689,13 @@ var TypeScript; var declFlags = 0 /* None */; - var span = TypeScript.TextSpan.fromBounds(objectType.start(), objectType.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl("", "", 8388608 /* ObjectType */, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl("", "", 8388608 /* ObjectType */, declFlags, parent); context.semanticInfoChain.setDeclForAST(objectType, decl); context.semanticInfoChain.setASTForDecl(decl, objectType); @@ -50290,10 +51709,9 @@ var TypeScript; declFlags |= 1 /* Exported */; } - var span = TypeScript.TextSpan.fromBounds(interfaceDecl.start(), interfaceDecl.end()); var parent = context.getParent(); - var decl = new TypeScript.NormalPullDecl(interfaceDecl.identifier.valueText(), interfaceDecl.identifier.text(), 16 /* Interface */, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(interfaceDecl.identifier.valueText(), interfaceDecl.identifier.text(), 16 /* Interface */, declFlags, parent); context.semanticInfoChain.setDeclForAST(interfaceDecl, decl); context.semanticInfoChain.setASTForDecl(decl, interfaceDecl); @@ -50319,15 +51737,13 @@ var TypeScript; declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var span = TypeScript.TextSpan.fromBounds(argDecl.start(), argDecl.end()); - - var decl = new TypeScript.NormalPullDecl(argDecl.identifier.valueText(), argDecl.identifier.text(), 2048 /* Parameter */, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(argDecl.identifier.valueText(), argDecl.identifier.text(), 2048 /* Parameter */, declFlags, parent); if (argDecl.equalsValueClause) { parent.flags |= 33554432 /* HasDefaultArgs */; } - if (parent.kind == 32768 /* ConstructorMethod */) { + if (parent.kind === 32768 /* ConstructorMethod */) { decl.setFlag(67108864 /* ConstructorParameter */); } @@ -50335,12 +51751,14 @@ var TypeScript; var isInConstructor = parent.kind === 32768 /* ConstructorMethod */; if (isPublicOrPrivate && isInConstructor) { var parentsParent = context.parentChain[context.parentChain.length - 2]; - var propDecl = new TypeScript.NormalPullDecl(argDecl.identifier.valueText(), argDecl.identifier.text(), 4096 /* Property */, declFlags, parentsParent, span); + + var propDeclFlags = declFlags & ~128 /* Optional */; + var propDecl = new TypeScript.NormalPullDecl(argDecl.identifier.valueText(), argDecl.identifier.text(), 4096 /* Property */, propDeclFlags, parentsParent); propDecl.setValueDecl(decl); decl.setFlag(8388608 /* PropertyParameter */); propDecl.setFlag(8388608 /* PropertyParameter */); - if (parent.kind == 32768 /* ConstructorMethod */) { + if (parent.kind === 32768 /* ConstructorMethod */) { propDecl.setFlag(67108864 /* ConstructorParameter */); } @@ -50358,15 +51776,13 @@ var TypeScript; function preCollectTypeParameterDecl(typeParameterDecl, context) { var declFlags = 0 /* None */; - var span = TypeScript.TextSpan.fromBounds(typeParameterDecl.start(), typeParameterDecl.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl(typeParameterDecl.identifier.valueText(), typeParameterDecl.identifier.text(), 8192 /* TypeParameter */, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(typeParameterDecl.identifier.valueText(), typeParameterDecl.identifier.text(), 8192 /* TypeParameter */, declFlags, parent); context.semanticInfoChain.setASTForDecl(decl, typeParameterDecl); context.semanticInfoChain.setDeclForAST(typeParameterDecl, decl); } @@ -50380,9 +51796,7 @@ var TypeScript; declFlags |= 128 /* Optional */; } - var span = TypeScript.TextSpan.fromBounds(propertyDecl.start(), propertyDecl.end()); - - var decl = new TypeScript.NormalPullDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(propertyDecl, decl); context.semanticInfoChain.setASTForDecl(decl, propertyDecl); } @@ -50401,10 +51815,9 @@ var TypeScript; declFlags |= 16 /* Static */; } - var span = TypeScript.TextSpan.fromBounds(memberDecl.start(), memberDecl.end()); var parent = context.getParent(); - var decl = new TypeScript.NormalPullDecl(memberDecl.variableDeclarator.propertyName.valueText(), memberDecl.variableDeclarator.propertyName.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(memberDecl.variableDeclarator.propertyName.valueText(), memberDecl.variableDeclarator.propertyName.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(memberDecl, decl); context.semanticInfoChain.setDeclForAST(memberDecl.variableDeclarator, decl); context.semanticInfoChain.setASTForDecl(decl, memberDecl); @@ -50414,7 +51827,7 @@ var TypeScript; var declFlags = 0 /* None */; var declType = 512 /* Variable */; - var modifiers = TypeScript.getVariableDeclaratorModifiers(varDecl); + var modifiers = TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl); if ((TypeScript.hasModifier(modifiers, 1 /* Exported */) || isParsingAmbientModule(varDecl, context)) && !containingModuleHasExportAssignment(varDecl)) { declFlags |= 1 /* Exported */; } @@ -50423,15 +51836,13 @@ var TypeScript; declFlags |= 8 /* Ambient */; } - var span = TypeScript.TextSpan.fromBounds(varDecl.start(), varDecl.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl(varDecl.propertyName.valueText(), varDecl.propertyName.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(varDecl.propertyName.valueText(), varDecl.propertyName.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(varDecl, decl); context.semanticInfoChain.setASTForDecl(decl, varDecl); @@ -50453,15 +51864,13 @@ var TypeScript; var declFlags = 2048 /* Signature */; var declType = 16777216 /* FunctionType */; - var span = TypeScript.TextSpan.fromBounds(functionTypeDeclAST.start(), functionTypeDeclAST.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(functionTypeDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, functionTypeDeclAST); @@ -50472,15 +51881,13 @@ var TypeScript; var declFlags = 0 /* None */; var declType = 33554432 /* ConstructorType */; - var span = TypeScript.TextSpan.fromBounds(constructorTypeDeclAST.start(), constructorTypeDeclAST.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(constructorTypeDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, constructorTypeDeclAST); @@ -50503,15 +51910,13 @@ var TypeScript; declFlags |= 2048 /* Signature */; } - var span = TypeScript.TextSpan.fromBounds(funcDeclAST.start(), funcDeclAST.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl(funcDeclAST.identifier.valueText(), funcDeclAST.identifier.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(funcDeclAST.identifier.valueText(), funcDeclAST.identifier.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(funcDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, funcDeclAST); @@ -50526,8 +51931,6 @@ var TypeScript; declFlags |= 8192 /* ArrowFunction */; } - var span = TypeScript.TextSpan.fromBounds(functionExpressionDeclAST.start(), functionExpressionDeclAST.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { @@ -50536,7 +51939,7 @@ var TypeScript; var name = id ? id.text() : ""; var displayNameText = displayName ? displayName.text() : ""; - var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, parent, span, displayNameText); + var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, parent, displayNameText); context.semanticInfoChain.setDeclForAST(functionExpressionDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, functionExpressionDeclAST); @@ -50552,9 +51955,7 @@ var TypeScript; declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var span = TypeScript.TextSpan.fromBounds(simpleArrow.identifier.start(), simpleArrow.identifier.end()); - - var decl = new TypeScript.NormalPullDecl(simpleArrow.identifier.valueText(), simpleArrow.identifier.text(), 2048 /* Parameter */, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(simpleArrow.identifier.valueText(), simpleArrow.identifier.text(), 2048 /* Parameter */, declFlags, parent); context.semanticInfoChain.setASTForDecl(decl, simpleArrow.identifier); context.semanticInfoChain.setDeclForAST(simpleArrow.identifier, decl); @@ -50581,10 +51982,9 @@ var TypeScript; declFlags |= 2048 /* Signature */; } - var span = TypeScript.TextSpan.fromBounds(funcDecl.start(), funcDecl.end()); var parent = context.getParent(); - var decl = new TypeScript.NormalPullDecl(funcDecl.propertyName.valueText(), funcDecl.propertyName.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(funcDecl.propertyName.valueText(), funcDecl.propertyName.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(funcDecl, decl); context.semanticInfoChain.setASTForDecl(decl, funcDecl); @@ -50595,11 +51995,9 @@ var TypeScript; var declFlags = 2048 /* Signature */; var declType = 4194304 /* IndexSignature */; - var span = TypeScript.TextSpan.fromBounds(indexSignatureDeclAST.start(), indexSignatureDeclAST.end()); - var parent = context.getParent(); - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(indexSignatureDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, indexSignatureDeclAST); @@ -50616,15 +52014,13 @@ var TypeScript; var declFlags = 2048 /* Signature */; var declType = 1048576 /* CallSignature */; - var span = TypeScript.TextSpan.fromBounds(callSignature.start(), callSignature.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(callSignature, decl); context.semanticInfoChain.setASTForDecl(decl, callSignature); @@ -50642,10 +52038,9 @@ var TypeScript; declFlags |= 128 /* Optional */; } - var span = TypeScript.TextSpan.fromBounds(method.start(), method.end()); var parent = context.getParent(); - var decl = new TypeScript.NormalPullDecl(method.propertyName.valueText(), method.propertyName.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(method.propertyName.valueText(), method.propertyName.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(method, decl); context.semanticInfoChain.setASTForDecl(decl, method); @@ -50656,15 +52051,13 @@ var TypeScript; var declFlags = 2048 /* Signature */; var declType = 2097152 /* ConstructSignature */; - var span = TypeScript.TextSpan.fromBounds(constructSignatureDeclAST.start(), constructSignatureDeclAST.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(constructSignatureDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, constructSignatureDeclAST); @@ -50679,8 +52072,6 @@ var TypeScript; declFlags |= 2048 /* Signature */; } - var span = TypeScript.TextSpan.fromBounds(constructorDeclAST.start(), constructorDeclAST.end()); - var parent = context.getParent(); if (parent) { @@ -50691,7 +52082,7 @@ var TypeScript; } } - var decl = new TypeScript.NormalPullDecl(parent.name, parent.getDisplayName(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(parent.name, parent.getDisplayName(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(constructorDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, constructorDeclAST); @@ -50712,15 +52103,13 @@ var TypeScript; declFlags |= 4 /* Public */; } - var span = TypeScript.TextSpan.fromBounds(getAccessorDeclAST.start(), getAccessorDeclAST.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl(getAccessorDeclAST.propertyName.valueText(), getAccessorDeclAST.propertyName.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(getAccessorDeclAST.propertyName.valueText(), getAccessorDeclAST.propertyName.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(getAccessorDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, getAccessorDeclAST); @@ -50745,15 +52134,13 @@ var TypeScript; declFlags |= 4 /* Public */; } - var span = TypeScript.TextSpan.fromBounds(setAccessorDeclAST.start(), setAccessorDeclAST.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl(setAccessorDeclAST.propertyName.valueText(), setAccessorDeclAST.propertyName.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(setAccessorDeclAST.propertyName.valueText(), setAccessorDeclAST.propertyName.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(setAccessorDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, setAccessorDeclAST); @@ -50764,15 +52151,13 @@ var TypeScript; var declFlags = 0 /* None */; var declType = 268435456 /* CatchBlock */; - var span = TypeScript.TextSpan.fromBounds(ast.start(), ast.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(ast, decl); context.semanticInfoChain.setASTForDecl(decl, ast); @@ -50781,15 +52166,13 @@ var TypeScript; var declFlags = 0 /* None */; var declType = 1024 /* CatchVariable */; - var span = TypeScript.TextSpan.fromBounds(ast.identifier.start(), ast.identifier.end()); - var parent = context.getParent(); if (TypeScript.hasFlag(parent.flags, 2097152 /* DeclaredInAWithBlock */)) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl(ast.identifier.valueText(), ast.identifier.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(ast.identifier.valueText(), ast.identifier.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(ast.identifier, decl); context.semanticInfoChain.setASTForDecl(decl, ast.identifier); @@ -50802,11 +52185,9 @@ var TypeScript; var declFlags = 0 /* None */; var declType = 134217728 /* WithBlock */; - var span = TypeScript.TextSpan.fromBounds(ast.start(), ast.end()); - var parent = context.getParent(); - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(ast, decl); context.semanticInfoChain.setASTForDecl(decl, ast); @@ -50814,8 +52195,7 @@ var TypeScript; } function preCollectObjectLiteralDecls(ast, context) { - var span = TypeScript.TextSpan.fromBounds(ast.start(), ast.end()); - var decl = new TypeScript.NormalPullDecl("", "", 256 /* ObjectLiteral */, 0 /* None */, context.getParent(), span); + var decl = new TypeScript.NormalPullDecl("", "", 256 /* ObjectLiteral */, 0 /* None */, context.getParent()); context.semanticInfoChain.setDeclForAST(ast, decl); context.semanticInfoChain.setASTForDecl(decl, ast); @@ -50827,7 +52207,7 @@ var TypeScript; var assignmentText = TypeScript.getPropertyAssignmentNameTextFromIdentifier(propertyAssignment.propertyName); var span = TypeScript.TextSpan.fromBounds(propertyAssignment.start(), propertyAssignment.end()); - var decl = new TypeScript.NormalPullDecl(assignmentText.memberName, assignmentText.actualText, 4096 /* Property */, 4 /* Public */, context.getParent(), span); + var decl = new TypeScript.NormalPullDecl(assignmentText.memberName, assignmentText.actualText, 4096 /* Property */, 4 /* Public */, context.getParent()); context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); @@ -50835,9 +52215,8 @@ var TypeScript; function preCollectFunctionPropertyAssignmentDecls(propertyAssignment, context) { var assignmentText = TypeScript.getPropertyAssignmentNameTextFromIdentifier(propertyAssignment.propertyName); - var span = TypeScript.TextSpan.fromBounds(propertyAssignment.start(), propertyAssignment.end()); - var decl = new TypeScript.NormalPullDecl(assignmentText.memberName, assignmentText.actualText, 4096 /* Property */, 4 /* Public */, context.getParent(), span); + var decl = new TypeScript.NormalPullDecl(assignmentText.memberName, assignmentText.actualText, 4096 /* Property */, 4 /* Public */, context.getParent()); context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); @@ -51043,7 +52422,7 @@ var TypeScript; function computeEnumElementConstantValue(expression, enumMemberDecls, context) { TypeScript.Debug.assert(expression); - if (TypeScript.isIntegerLiteralAST(expression)) { + if (TypeScript.ASTHelpers.isIntegerLiteralAST(expression)) { var token; switch (expression.kind()) { case 164 /* PlusExpression */: @@ -51111,12 +52490,13 @@ var TypeScript; function PullSymbolBinder(semanticInfoChain) { this.semanticInfoChain = semanticInfoChain; this.declsBeingBound = []; + this.inBindingOtherDeclsWalker = new TypeScript.PullHelpers.OtherPullDeclsWalker(); } PullSymbolBinder.prototype.getParent = function (decl, returnInstanceType) { if (typeof returnInstanceType === "undefined") { returnInstanceType = false; } var parentDecl = decl.getParentDecl(); - if (parentDecl.kind == 1 /* Script */) { + if (parentDecl.kind === 1 /* Script */) { return null; } @@ -51129,9 +52509,9 @@ var TypeScript; parent = parentDecl.getSymbol(); if (parent) { var parentDeclKind = parentDecl.kind; - if (parentDeclKind == 262144 /* GetAccessor */) { + if (parentDeclKind === 262144 /* GetAccessor */) { parent = parent.getGetter(); - } else if (parentDeclKind == 524288 /* SetAccessor */) { + } else if (parentDeclKind === 524288 /* SetAccessor */) { parent = parent.getSetter(); } } @@ -51175,7 +52555,7 @@ var TypeScript; PullSymbolBinder.prototype.getExistingSymbol = function (decl, searchKind, parent) { var lookingForValue = (searchKind & 68147712 /* SomeValue */) !== 0; - var lookingForType = (searchKind & 58728539 /* SomeType */) !== 0; + var lookingForType = (searchKind & 58728795 /* SomeType */) !== 0; var lookingForContainer = (searchKind & 164 /* SomeContainer */) !== 0; var name = decl.name; if (parent) { @@ -51232,7 +52612,7 @@ var TypeScript; var isExported = (decl.flags & 1 /* Exported */) !== 0; var prevDecls = prevSymbol.getDeclarations(); var prevIsExported = (prevDecls[prevDecls.length - 1].flags & 1 /* Exported */) !== 0; - if ((isExported !== prevIsExported) && !prevSymbol.isSignature() && (decl.kind & 7340032 /* SomeSignature */) == 0) { + if ((isExported !== prevIsExported) && !prevSymbol.isSignature() && (decl.kind & 7340032 /* SomeSignature */) === 0) { if (reportError) { var ast = this.semanticInfoChain.getASTForDecl(decl); this.semanticInfoChain.addDiagnosticFromAST(ast, TypeScript.DiagnosticCode.All_declarations_of_merged_declaration_0_must_be_exported_or_not_exported, [decl.getDisplayName()]); @@ -51243,6 +52623,16 @@ var TypeScript; return true; }; + PullSymbolBinder.prototype.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList = function (signature, currentSignatures) { + var signatureDecl = signature.getDeclarations()[0]; + TypeScript.Debug.assert(signatureDecl); + var enclosingDecl = signatureDecl.getParentDecl(); + var indexToInsert = TypeScript.ArrayUtilities.indexOf(currentSignatures, function (someSignature) { + return someSignature.getDeclarations()[0].getParentDecl() !== enclosingDecl; + }); + return indexToInsert < 0 ? currentSignatures.length : indexToInsert; + }; + PullSymbolBinder.prototype.bindEnumDeclarationToPullSymbol = function (enumContainerDecl) { var enumName = enumContainerDecl.name; @@ -51260,7 +52650,6 @@ var TypeScript; var enumAST = this.semanticInfoChain.getASTForDecl(enumContainerDecl); var isExported = enumContainerDecl.flags & 1 /* Exported */; - var isInitializedModule = (enumContainerDecl.flags & 102400 /* SomeInitializedModule */) != 0; var createdNewSymbol = false; @@ -51268,9 +52657,7 @@ var TypeScript; if (enumContainerSymbol) { if (enumContainerSymbol.kind !== enumDeclKind) { - if (isInitializedModule) { - this.semanticInfoChain.addDiagnosticFromAST(enumAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [enumContainerDecl.getDisplayName()]); - } + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(enumAST.identifier, enumContainerDecl.getDisplayName(), enumContainerSymbol.getDeclarations()[0].ast()); enumContainerSymbol = null; } else if (!this.checkThatExportsMatch(enumContainerDecl, enumContainerSymbol)) { enumContainerSymbol = null; @@ -51294,7 +52681,7 @@ var TypeScript; this.semanticInfoChain.setSymbolForAST(enumAST.identifier, enumContainerSymbol); this.semanticInfoChain.setSymbolForAST(enumAST, enumContainerSymbol); - if (!enumInstanceSymbol && isInitializedModule) { + if (!enumInstanceSymbol) { var variableSymbol = null; if (parentInstanceSymbol) { if (isExported) { @@ -51327,11 +52714,11 @@ var TypeScript; var augmentedDecl = null; for (var i = 0; i < siblingDecls.length; i++) { - if (siblingDecls[i] == enumContainerDecl) { + if (siblingDecls[i] === enumContainerDecl) { break; } - if ((siblingDecls[i].name == enumName) && (siblingDecls[i].kind & 68147712 /* SomeValue */)) { + if ((siblingDecls[i].name === enumName) && (siblingDecls[i].kind & 68147712 /* SomeValue */)) { augmentedDecl = siblingDecls[i]; break; } @@ -51371,20 +52758,6 @@ var TypeScript; } } - var moduleDeclarations = enumContainerSymbol.getDeclarations(); - - if (moduleDeclarations.length > 1 && enumAST.enumElements.nonSeparatorCount() > 0) { - var multipleEnums = TypeScript.ArrayUtilities.where(moduleDeclarations, function (d) { - return d.kind === 64 /* Enum */; - }).length > 1; - if (multipleEnums) { - var firstVariable = enumAST.enumElements.nonSeparatorAt(0); - if (!firstVariable.equalsValueClause) { - this.semanticInfoChain.addDiagnosticFromAST(firstVariable, TypeScript.DiagnosticCode.Enums_with_multiple_declarations_must_provide_an_initializer_for_the_first_enum_element, null); - } - } - } - if (createdNewSymbol && parent) { if (enumContainerDecl.flags & 1 /* Exported */) { parent.addEnclosedMemberType(enumContainerSymbol); @@ -51393,65 +52766,111 @@ var TypeScript; } } - this.bindEnumIndexerDeclsToPullSymbols(enumContainerDecl, enumContainerSymbol); - + if (createdNewSymbol) { + this.bindEnumIndexerDeclsToPullSymbols(enumContainerSymbol); + } var valueDecl = enumContainerDecl.getValueDecl(); if (valueDecl) { valueDecl.ensureSymbolIsBound(); } - - var otherDecls = this.findDeclsInContext(enumContainerDecl, enumContainerDecl.kind, true); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } }; - PullSymbolBinder.prototype.bindEnumIndexerDeclsToPullSymbols = function (enumContainerDecl, enumContainerSymbol) { - var indexSigDecl = enumContainerDecl.getChildDecls().filter(function (decl) { - return decl.kind == 4194304 /* IndexSignature */; - })[0]; - var indexParamDecl = indexSigDecl.getChildDecls()[0]; - - var syntheticIndexerParameterSymbol = new TypeScript.PullSymbol(indexParamDecl.name, 2048 /* Parameter */); + PullSymbolBinder.prototype.bindEnumIndexerDeclsToPullSymbols = function (enumContainerSymbol) { + var enumContainerInstanceTypeSymbol = enumContainerSymbol.getInstanceSymbol().type; + var syntheticIndexerParameterSymbol = new TypeScript.PullSymbol("x", 2048 /* Parameter */); syntheticIndexerParameterSymbol.type = this.semanticInfoChain.numberTypeSymbol; syntheticIndexerParameterSymbol.setResolved(); + syntheticIndexerParameterSymbol.setIsSynthesized(); var syntheticIndexerSignatureSymbol = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); syntheticIndexerSignatureSymbol.addParameter(syntheticIndexerParameterSymbol); syntheticIndexerSignatureSymbol.returnType = this.semanticInfoChain.stringTypeSymbol; syntheticIndexerSignatureSymbol.setResolved(); + syntheticIndexerSignatureSymbol.setIsSynthesized(); - var enumContainerInstanceTypeSymbol = enumContainerSymbol.getInstanceSymbol().type; enumContainerInstanceTypeSymbol.addIndexSignature(syntheticIndexerSignatureSymbol); + }; - indexSigDecl.setSignatureSymbol(syntheticIndexerSignatureSymbol); - indexParamDecl.setSymbol(syntheticIndexerParameterSymbol); + PullSymbolBinder.prototype.findExistingVariableSymbolForModuleValueDecl = function (decl) { + var isExported = TypeScript.hasFlag(decl.flags, 1 /* Exported */); + var modName = decl.name; + var parentInstanceSymbol = this.getParent(decl, true); + var parentDecl = decl.getParentDecl(); - syntheticIndexerSignatureSymbol.addDeclaration(indexSigDecl); - syntheticIndexerParameterSymbol.addDeclaration(indexParamDecl); + var variableSymbol = null; + + if (parentInstanceSymbol) { + if (isExported) { + variableSymbol = parentInstanceSymbol.findMember(modName, false); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findContainedNonMember(modName); + } + } else { + variableSymbol = parentInstanceSymbol.findContainedNonMember(modName); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findMember(modName, false); + } + } + + if (variableSymbol) { + var declarations = variableSymbol.getDeclarations(); + + if (declarations.length) { + var variableSymbolParentDecl = declarations[0].getParentDecl(); + var isExportedOrHasTheSameParent = isExported || (parentDecl === variableSymbolParentDecl); + + var canReuseVariableSymbol = isExportedOrHasTheSameParent && this.checkThatExportsMatch(decl, variableSymbol, false); + + if (!canReuseVariableSymbol) { + variableSymbol = null; + } + } + } + } else if (!isExported) { + var siblingDecls = parentDecl.getChildDecls(); + + for (var i = 0; i < siblingDecls.length; i++) { + var sibling = siblingDecls[i]; + + var siblingIsSomeValue = TypeScript.hasFlag(sibling.kind, 68147712 /* SomeValue */); + var siblingIsFunctionOrHasImplictVarFlag = TypeScript.hasFlag(sibling.kind, 1032192 /* SomeFunction */) || TypeScript.hasFlag(sibling.flags, 118784 /* ImplicitVariable */); + + var isSiblingAnAugmentableVariable = sibling !== decl && sibling !== decl.getValueDecl() && sibling.name === modName && siblingIsSomeValue && siblingIsFunctionOrHasImplictVarFlag; + + if (isSiblingAnAugmentableVariable) { + if (sibling.hasSymbol()) { + variableSymbol = sibling.getSymbol(); + if (variableSymbol.isContainer()) { + variableSymbol = variableSymbol.getInstanceSymbol(); + } else if (variableSymbol && variableSymbol.isType()) { + variableSymbol = variableSymbol.getConstructorMethod(); + } + + break; + } + } + } + } + return variableSymbol; }; PullSymbolBinder.prototype.bindModuleDeclarationToPullSymbol = function (moduleContainerDecl) { var modName = moduleContainerDecl.name; var moduleContainerTypeSymbol = null; - var moduleInstanceSymbol = null; - var moduleInstanceTypeSymbol = null; - var moduleKind = moduleContainerDecl.kind; var parent = this.getParent(moduleContainerDecl); var parentInstanceSymbol = this.getParent(moduleContainerDecl, true); var parentDecl = moduleContainerDecl.getParentDecl(); var moduleNameAST = this.semanticInfoChain.getASTForDecl(moduleContainerDecl); - var moduleDeclAST = TypeScript.getEnclosingModuleDeclaration(moduleNameAST); + var moduleDeclAST = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(moduleNameAST); if (!moduleDeclAST) { - TypeScript.Debug.assert(moduleContainerDecl.kind === 32 /* DynamicModule */); + TypeScript.Debug.assert(moduleKind === 32 /* DynamicModule */); TypeScript.Debug.assert(moduleNameAST.kind() === 120 /* SourceUnit */); moduleDeclAST = moduleNameAST; @@ -51459,9 +52878,9 @@ var TypeScript; var isExported = TypeScript.hasFlag(moduleContainerDecl.flags, 1 /* Exported */); var searchKind = 164 /* SomeContainer */; - var isInitializedModule = (moduleContainerDecl.flags & 102400 /* SomeInitializedModule */) != 0; + var isInitializedModule = (moduleContainerDecl.flags & 102400 /* SomeInitializedModule */) !== 0; - if (parent && moduleKind == 32 /* DynamicModule */) { + if (parent && moduleKind === 32 /* DynamicModule */) { this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Ambient_external_module_declaration_must_be_defined_in_global_context, null); } @@ -51472,20 +52891,18 @@ var TypeScript; if (moduleContainerTypeSymbol) { if (moduleContainerTypeSymbol.kind !== moduleKind) { if (isInitializedModule) { - this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [moduleContainerDecl.getDisplayName()]); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(moduleNameAST, moduleContainerDecl.getDisplayName(), moduleContainerTypeSymbol.getDeclarations()[0].ast()); } moduleContainerTypeSymbol = null; - } else if (moduleKind == 32 /* DynamicModule */) { + } else if (moduleKind === 32 /* DynamicModule */) { this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Ambient_external_module_declaration_cannot_be_reopened); } else if (!this.checkThatExportsMatch(moduleContainerDecl, moduleContainerTypeSymbol)) { moduleContainerTypeSymbol = null; } } - if (moduleContainerTypeSymbol) { - moduleInstanceSymbol = moduleContainerTypeSymbol.getInstanceSymbol(); - } else { + if (!moduleContainerTypeSymbol) { moduleContainerTypeSymbol = new TypeScript.PullContainerSymbol(modName, moduleKind); createdNewSymbol = true; @@ -51500,74 +52917,7 @@ var TypeScript; this.semanticInfoChain.setSymbolForAST(moduleNameAST, moduleContainerTypeSymbol); this.semanticInfoChain.setSymbolForAST(moduleDeclAST, moduleContainerTypeSymbol); - if (!moduleInstanceSymbol && isInitializedModule) { - var variableSymbol = null; - if (parentInstanceSymbol) { - if (isExported) { - variableSymbol = parentInstanceSymbol.findMember(modName, false); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findContainedNonMember(modName); - } - } else { - variableSymbol = parentInstanceSymbol.findContainedNonMember(modName); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findMember(modName, false); - } - } - - if (variableSymbol) { - var declarations = variableSymbol.getDeclarations(); - - if (declarations.length) { - var variableSymbolParentDecl = declarations[0].getParentDecl(); - - if (parentDecl !== variableSymbolParentDecl) { - variableSymbol = null; - } - } - } - } else if (!isExported) { - var siblingDecls = parentDecl.getChildDecls(); - - for (var i = 0; i < siblingDecls.length; i++) { - var sibling = siblingDecls[i]; - if (sibling !== moduleContainerDecl && sibling.name === modName && TypeScript.hasFlag(sibling.kind, 68147712 /* SomeValue */)) { - if (sibling.hasSymbol()) { - variableSymbol = sibling.getSymbol(); - if (variableSymbol.isContainer()) { - variableSymbol = variableSymbol.getInstanceSymbol(); - } else if (variableSymbol && variableSymbol.isType()) { - variableSymbol = variableSymbol.getConstructorMethod(); - } - - break; - } - } - } - } - - if (variableSymbol) { - moduleInstanceSymbol = variableSymbol; - moduleInstanceTypeSymbol = variableSymbol.type; - } else { - moduleInstanceSymbol = new TypeScript.PullSymbol(modName, 512 /* Variable */); - } - - moduleContainerTypeSymbol.setInstanceSymbol(moduleInstanceSymbol); - - if (!moduleInstanceTypeSymbol) { - moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - moduleInstanceSymbol.type = moduleInstanceTypeSymbol; - } - - moduleInstanceTypeSymbol.addDeclaration(moduleContainerDecl); - - if (!moduleInstanceTypeSymbol.getAssociatedContainerType()) { - moduleInstanceTypeSymbol.setAssociatedContainerType(moduleContainerTypeSymbol); - } - } + var currentModuleValueDecl = moduleContainerDecl.getValueDecl(); var moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); @@ -51581,24 +52931,29 @@ var TypeScript; } } - var valueDecl = moduleContainerDecl.getValueDecl(); + if (currentModuleValueDecl) { + currentModuleValueDecl.ensureSymbolIsBound(); - if (valueDecl) { - valueDecl.ensureSymbolIsBound(); - - if (!valueDecl.hasSymbol()) { - valueDecl.setSymbol(moduleInstanceSymbol); - if (!moduleInstanceSymbol.hasDeclaration(valueDecl)) { - moduleInstanceSymbol.addDeclaration(valueDecl); + var instanceSymbol = null; + var instanceTypeSymbol = null; + if (currentModuleValueDecl.hasSymbol()) { + instanceSymbol = currentModuleValueDecl.getSymbol(); + } else { + instanceSymbol = new TypeScript.PullSymbol(modName, 512 /* Variable */); + currentModuleValueDecl.setSymbol(instanceSymbol); + if (!instanceSymbol.hasDeclaration(currentModuleValueDecl)) { + instanceSymbol.addDeclaration(currentModuleValueDecl); } } - } - var otherDecls = this.findDeclsInContext(moduleContainerDecl, moduleContainerDecl.kind, true); + if (!instanceSymbol.type) { + instanceSymbol.type = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + } - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); + moduleContainerTypeSymbol.setInstanceSymbol(instanceSymbol); + + if (!instanceSymbol.type.getAssociatedContainerType()) { + instanceSymbol.type.setAssociatedContainerType(moduleContainerTypeSymbol); } } }; @@ -51621,7 +52976,7 @@ var TypeScript; } if (importSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(importDeclAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [importDeclaration.getDisplayName()]); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(importDeclAST, importDeclaration.getDisplayName(), importSymbol.getDeclarations()[0].ast()); importSymbol = null; } @@ -51647,6 +53002,28 @@ var TypeScript; } }; + PullSymbolBinder.prototype.ensurePriorDeclarationsAreBound = function (container, currentDecl) { + if (!container) { + return; + } + + var parentDecls = container.getDeclarations(); + for (var i = 0; i < parentDecls.length; ++i) { + var parentDecl = parentDecls[i]; + var childDecls = parentDecl.getChildDecls(); + for (var j = 0; j < childDecls.length; ++j) { + var childDecl = childDecls[j]; + if (childDecl === currentDecl) { + return; + } + + if (childDecl.name === currentDecl.name) { + childDecl.ensureSymbolIsBound(); + } + } + } + }; + PullSymbolBinder.prototype.bindClassDeclarationToPullSymbol = function (classDecl) { var className = classDecl.name; var classSymbol = null; @@ -51657,19 +53034,20 @@ var TypeScript; var classAST = this.semanticInfoChain.getASTForDecl(classDecl); var parent = this.getParent(classDecl); + + this.ensurePriorDeclarationsAreBound(parent, classDecl); + var parentDecl = classDecl.getParentDecl(); var isExported = classDecl.flags & 1 /* Exported */; var isGeneric = false; - classSymbol = this.getExistingSymbol(classDecl, 58728539 /* SomeType */, parent); + classSymbol = this.getExistingSymbol(classDecl, 58728795 /* SomeType */, parent); if (classSymbol && classSymbol.kind === 16 /* Interface */) { - this.semanticInfoChain.addDiagnosticFromAST(classAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [classDecl.getDisplayName()]); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(classAST.identifier, classDecl.getDisplayName(), classSymbol.getDeclarations()[0].ast()); classSymbol = null; } - var decls; - classSymbol = new TypeScript.PullTypeSymbol(className, 8 /* Class */); if (!parent) { @@ -51691,6 +53069,23 @@ var TypeScript; } } + var typeParameterDecls = classDecl.getTypeParameters(); + + for (var i = 0; i < typeParameterDecls.length; i++) { + var typeParameterSymbol = classSymbol.findTypeParameter(typeParameterDecls[i].name); + + if (typeParameterSymbol) { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterSymbol.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameterSymbol.getName()]); + } + + typeParameterSymbol = new TypeScript.PullTypeParameterSymbol(typeParameterDecls[i].name); + + classSymbol.addTypeParameter(typeParameterSymbol); + typeParameterSymbol.addDeclaration(typeParameterDecls[i]); + typeParameterDecls[i].setSymbol(typeParameterSymbol); + } + constructorSymbol = classSymbol.getConstructorMethod(); constructorTypeSymbol = constructorSymbol ? constructorSymbol.type : null; @@ -51726,32 +53121,13 @@ var TypeScript; constructorTypeSymbol.setAssociatedContainerType(classSymbol); - var typeParameters = classDecl.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = classSymbol.findTypeParameter(typeParameters[i].name); - - if (typeParameter != null) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); - - classSymbol.addTypeParameter(typeParameter); - constructorTypeSymbol.addConstructorTypeParameter(typeParameter); - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - var valueDecl = classDecl.getValueDecl(); if (valueDecl) { valueDecl.ensureSymbolIsBound(); } - this.bindStaticPrototypePropertyOfClass(classSymbol, constructorTypeSymbol); + this.bindStaticPrototypePropertyOfClass(classAST, classSymbol, constructorTypeSymbol); }; PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { @@ -51764,11 +53140,11 @@ var TypeScript; var acceptableSharedKind = 16 /* Interface */; - interfaceSymbol = this.getExistingSymbol(interfaceDecl, 58728539 /* SomeType */, parent); + interfaceSymbol = this.getExistingSymbol(interfaceDecl, 58728795 /* SomeType */, parent); if (interfaceSymbol) { if (!(interfaceSymbol.kind & acceptableSharedKind)) { - this.semanticInfoChain.addDiagnosticFromAST(interfaceAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [interfaceDecl.getDisplayName()]); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(interfaceAST.identifier, interfaceDecl.getDisplayName(), interfaceSymbol.getDeclarations()[0].ast()); interfaceSymbol = null; } else if (!this.checkThatExportsMatch(interfaceDecl, interfaceSymbol)) { interfaceSymbol = null; @@ -51805,7 +53181,7 @@ var TypeScript; typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].name); if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); interfaceSymbol.addTypeParameter(typeParameter); } else { @@ -51826,14 +53202,6 @@ var TypeScript; typeParameter.addDeclaration(typeParameters[i]); typeParameters[i].setSymbol(typeParameter); } - - var otherDecls = this.findDeclsInContext(interfaceDecl, interfaceDecl.kind, true); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } }; PullSymbolBinder.prototype.bindObjectTypeDeclarationToPullSymbol = function (objectDecl) { @@ -51874,9 +53242,7 @@ var TypeScript; signature.addDeclaration(constructorTypeDeclaration); constructorTypeDeclaration.setSignatureSymbol(signature); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(funcDecl.parameterList), constructorTypeSymbol, signature); - - constructorTypeSymbol.addConstructSignature(signature); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), constructorTypeSymbol, signature); var typeParameters = constructorTypeDeclaration.getTypeParameters(); var typeParameter; @@ -51885,9 +53251,9 @@ var TypeScript; typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].name); if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - constructorTypeSymbol.addConstructorTypeParameter(typeParameter); + signature.addTypeParameter(typeParameter); } else { var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); @@ -51896,12 +53262,15 @@ var TypeScript; typeParameter.addDeclaration(typeParameters[i]); typeParameters[i].setSymbol(typeParameter); } + + constructorTypeSymbol.appendConstructSignature(signature); }; PullSymbolBinder.prototype.bindVariableDeclarationToPullSymbol = function (variableDeclaration) { var declFlags = variableDeclaration.flags; var declKind = variableDeclaration.kind; var varDeclAST = this.semanticInfoChain.getASTForDecl(variableDeclaration); + var nameAST = varDeclAST.kind() === 131 /* ClassDeclaration */ ? varDeclAST.identifier : varDeclAST.kind() === 225 /* VariableDeclarator */ ? varDeclAST.propertyName : varDeclAST.kind() === 132 /* EnumDeclaration */ ? varDeclAST.identifier : varDeclAST; var isExported = (declFlags & 1 /* Exported */) !== 0; @@ -51916,12 +53285,15 @@ var TypeScript; var parentDecl = variableDeclaration.getParentDecl(); var isImplicit = (declFlags & 118784 /* ImplicitVariable */) !== 0; - var isModuleValue = (declFlags & (32768 /* InitializedModule */)) != 0; - var isEnumValue = (declFlags & 4096 /* Enum */) != 0; - var isClassConstructorVariable = (declFlags & 16384 /* ClassConstructorVariable */) != 0; - + var isModuleValue = (declFlags & (32768 /* InitializedModule */)) !== 0; + var isEnumValue = (declFlags & 4096 /* Enum */) !== 0; + var isClassConstructorVariable = (declFlags & 16384 /* ClassConstructorVariable */) !== 0; variableSymbol = this.getExistingSymbol(variableDeclaration, 68147712 /* SomeValue */, parent); + if (!variableSymbol && isModuleValue) { + variableSymbol = this.findExistingVariableSymbolForModuleValueDecl(variableDeclaration.getContainerDecl()); + } + if (variableSymbol && !variableSymbol.isType()) { parentHadSymbol = true; } @@ -51937,28 +53309,29 @@ var TypeScript; var prevIsClassConstructorVariable = variableSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */); var prevIsModuleValue = variableSymbol.allDeclsHaveFlag(32768 /* InitializedModule */); var prevIsImplicit = variableSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */); - var prevIsFunction = prevKind == 16384 /* Function */; + var prevIsFunction = TypeScript.ArrayUtilities.any(variableSymbol.getDeclarations(), function (decl) { + return decl.kind === 16384 /* Function */; + }); var prevIsAmbient = variableSymbol.allDeclsHaveFlag(8 /* Ambient */); - var isAmbientOrPrevIsAmbient = prevIsAmbient || (variableDeclaration.flags & 8 /* Ambient */) != 0; + var isAmbientOrPrevIsAmbient = prevIsAmbient || (variableDeclaration.flags & 8 /* Ambient */) !== 0; var prevDecl = variableSymbol.getDeclarations()[0]; var prevParentDecl = prevDecl.getParentDecl(); - var bothAreGlobal = parentDecl && (parentDecl.kind == 1 /* Script */) && (prevParentDecl.kind == 1 /* Script */); - var shareParent = bothAreGlobal || prevDecl.getParentDecl() == variableDeclaration.getParentDecl(); - var prevIsParam = shareParent && prevKind == 2048 /* Parameter */ && declKind == 512 /* Variable */; + var bothAreGlobal = parentDecl && (parentDecl.kind === 1 /* Script */) && (prevParentDecl.kind === 1 /* Script */); + var shareParent = bothAreGlobal || prevDecl.getParentDecl() === variableDeclaration.getParentDecl(); + var prevIsParam = shareParent && prevKind === 2048 /* Parameter */ && declKind == 512 /* Variable */; var acceptableRedeclaration = prevIsParam || (isImplicit && ((!isEnumValue && !isClassConstructorVariable && prevIsFunction) || ((isModuleValue || isEnumValue) && (prevIsModuleValue || prevIsEnum)) || (isClassConstructorVariable && prevIsModuleValue && isAmbientOrPrevIsAmbient) || (isModuleValue && prevIsClassConstructorVariable))); if (acceptableRedeclaration && (prevIsClassConstructorVariable || prevIsFunction) && !isAmbientOrPrevIsAmbient) { - if (prevDecl.fileName() != variableDeclaration.fileName()) { - this.semanticInfoChain.addDiagnostic(TypeScript.diagnosticFromDecl(variableDeclaration, TypeScript.DiagnosticCode.Module_0_cannot_merge_with_previous_declaration_of_1_in_a_different_file_2, [declName, declName, prevDecl.fileName()])); + if (prevDecl.fileName() !== variableDeclaration.fileName()) { + this.semanticInfoChain.addDiagnostic(TypeScript.PullHelpers.diagnosticFromDecl(variableDeclaration, TypeScript.DiagnosticCode.Module_0_cannot_merge_with_previous_declaration_of_1_in_a_different_file_2, [declName, declName, prevDecl.fileName()])); variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); } } if (!acceptableRedeclaration || prevIsParam) { - if (!prevIsParam && (isImplicit || prevIsImplicit || (prevKind & 1032192 /* SomeFunction */) !== 0) || !shareParent) { - var diagnostic = TypeScript.diagnosticFromDecl(variableDeclaration, TypeScript.DiagnosticCode.Duplicate_identifier_0, [variableDeclaration.getDisplayName()]); - this.semanticInfoChain.addDiagnostic(diagnostic); + if (!prevIsParam && (isImplicit || prevIsImplicit || TypeScript.hasFlag(prevKind, 1032192 /* SomeFunction */)) || !shareParent) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(nameAST, variableDeclaration.getDisplayName(), variableSymbol.getDeclarations()[0].ast()); variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); } else { this.checkThatExportsMatch(variableDeclaration, variableSymbol); @@ -51983,7 +53356,7 @@ var TypeScript; variableSymbol.addDeclaration(variableDeclaration); variableDeclaration.setSymbol(variableSymbol); - this.semanticInfoChain.setSymbolForAST(varDeclAST.propertyName, variableSymbol); + this.semanticInfoChain.setSymbolForAST(nameAST, variableSymbol); this.semanticInfoChain.setSymbolForAST(varDeclAST, variableSymbol); } else if (!parentHadSymbol) { if (isClassConstructorVariable) { @@ -52001,22 +53374,10 @@ var TypeScript; } if (!classTypeSymbol) { - var parentDecl = variableDeclaration.getParentDecl(); - - if (parentDecl) { - var childDecls = parentDecl.searchChildDecls(declName, 58728539 /* SomeType */); - - if (childDecls.length) { - for (var i = 0; i < childDecls.length; i++) { - if (childDecls[i].getValueDecl() === variableDeclaration) { - classTypeSymbol = childDecls[i].getSymbol(); - } - } - } - } - + var containerDecl = variableDeclaration.getContainerDecl(); + classTypeSymbol = containerDecl.getSymbol(); if (!classTypeSymbol) { - classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 58728539 /* SomeType */, variableDeclaration); + classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 58728795 /* SomeType */, variableDeclaration); } } @@ -52060,20 +53421,8 @@ var TypeScript; } if (!moduleContainerTypeSymbol) { - var parentDecl = variableDeclaration.getParentDecl(); - - if (parentDecl) { - var searchKind = (declFlags & (32768 /* InitializedModule */ | 65536 /* InitializedDynamicModule */)) ? 164 /* SomeContainer */ : 64 /* Enum */; - var childDecls = parentDecl.searchChildDecls(declName, searchKind); - - if (childDecls.length) { - for (var i = 0; i < childDecls.length; i++) { - if (childDecls[i].getValueDecl() === variableDeclaration) { - moduleContainerTypeSymbol = childDecls[i].getSymbol(); - } - } - } - } + var containerDecl = variableDeclaration.getContainerDecl(); + moduleContainerTypeSymbol = containerDecl.getSymbol(); if (!moduleContainerTypeSymbol) { moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 164 /* SomeContainer */, variableDeclaration); @@ -52089,6 +53438,10 @@ var TypeScript; if (moduleContainerTypeSymbol) { variableSymbol = moduleContainerTypeSymbol.getInstanceSymbol(); + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + variableSymbol.type = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + } if (!variableSymbol.hasDeclaration(variableDeclaration)) { variableSymbol.addDeclaration(variableDeclaration); @@ -52105,6 +53458,11 @@ var TypeScript; variableDeclaration.setSymbol(variableSymbol); } + var containerDecl = variableDeclaration.getContainerDecl(); + if (variableSymbol && variableSymbol.type && containerDecl && !variableSymbol.type.hasDeclaration(containerDecl)) { + variableSymbol.type.addDeclaration(containerDecl); + } + if (parent && !parentHadSymbol) { if (declFlags & 1 /* Exported */) { parent.addMember(variableSymbol); @@ -52112,14 +53470,6 @@ var TypeScript; parent.addEnclosedNonMember(variableSymbol); } } - - var otherDecls = this.findDeclsInContext(variableDeclaration, variableDeclaration.kind, false); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } }; PullSymbolBinder.prototype.bindCatchVariableToPullSymbol = function (variableDeclaration) { @@ -52153,7 +53503,7 @@ var TypeScript; var propertySymbol = parent.findMember(declName, false); if (propertySymbol) { - this.semanticInfoChain.addDiagnostic(TypeScript.diagnosticFromDecl(propertyDeclaration, TypeScript.DiagnosticCode.Duplicate_identifier_0, [propertyDeclaration.getDisplayName()])); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(propDeclAST.propertyName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); } if (propertySymbol) { @@ -52208,7 +53558,7 @@ var TypeScript; propertySymbol = parent.findMember(declName, false); if (propertySymbol) { - this.semanticInfoChain.addDiagnostic(TypeScript.diagnosticFromDecl(propertyDeclaration, TypeScript.DiagnosticCode.Duplicate_identifier_0, [propertyDeclaration.getDisplayName()])); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(astName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); } if (propertySymbol) { @@ -52253,28 +53603,33 @@ var TypeScript; parameterSymbol.isVarArg = true; } - if (decl.flags & 128 /* Optional */) { - parameterSymbol.isOptional = true; - } - if (params[id.valueText()]) { this.semanticInfoChain.addDiagnosticFromAST(argDecl, TypeScript.DiagnosticCode.Duplicate_identifier_0, [id.text()]); } else { params[id.valueText()] = true; } + if (decl) { + var isParameterOptional = false; + if (isProperty) { decl.ensureSymbolIsBound(); var valDecl = decl.getValueDecl(); if (valDecl) { + isParameterOptional = TypeScript.hasFlag(valDecl.flags, 128 /* Optional */); + valDecl.setSymbol(parameterSymbol); parameterSymbol.addDeclaration(valDecl); } } else { + isParameterOptional = TypeScript.hasFlag(decl.flags, 128 /* Optional */); + parameterSymbol.addDeclaration(decl); decl.setSymbol(parameterSymbol); } + + parameterSymbol.isOptional = isParameterOptional; } signatureSymbol.addParameter(parameterSymbol, parameterSymbol.isOptional); @@ -52298,6 +53653,7 @@ var TypeScript; var isSignature = (declFlags & 2048 /* Signature */) !== 0; var parent = this.getParent(functionDeclaration, true); + var parentDecl = functionDeclaration.getParentDecl(); var parentHadSymbol = false; @@ -52307,11 +53663,21 @@ var TypeScript; functionSymbol = this.getExistingSymbol(functionDeclaration, 68147712 /* SomeValue */, parent); if (functionSymbol) { - var previousIsAmbient = functionSymbol.allDeclsHaveFlag(8 /* Ambient */); - var isAmbientOrPreviousIsAmbient = previousIsAmbient || functionDeclaration.flags & 8 /* Ambient */; - var acceptableRedeclaration = functionSymbol.kind === 16384 /* Function */ && (isSignature || functionSymbol.allDeclsHaveFlag(2048 /* Signature */)) || functionSymbol.allDeclsHaveFlag(32768 /* InitializedModule */) && isAmbientOrPreviousIsAmbient; + var acceptableRedeclaration; + + if (functionSymbol.kind === 16384 /* Function */) { + acceptableRedeclaration = isSignature || functionSymbol.allDeclsHaveFlag(2048 /* Signature */); + } else { + var isCurrentDeclAmbient = TypeScript.hasFlag(functionDeclaration.flags, 8 /* Ambient */); + acceptableRedeclaration = TypeScript.ArrayUtilities.all(functionSymbol.getDeclarations(), function (decl) { + var isInitializedModuleOrAmbientDecl = TypeScript.hasFlag(decl.flags, 32768 /* InitializedModule */) && (isCurrentDeclAmbient || TypeScript.hasFlag(decl.flags, 8 /* Ambient */)); + var isSignature = TypeScript.hasFlag(decl.flags, 2048 /* Signature */); + return isInitializedModuleOrAmbientDecl || isSignature; + }); + } + if (!acceptableRedeclaration) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [functionDeclaration.getDisplayName()]); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.identifier, functionDeclaration.getDisplayName(), functionSymbol.getDeclarations()[0].ast()); functionSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(funcName); } } @@ -52346,7 +53712,7 @@ var TypeScript; } } - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); signature.addDeclaration(functionDeclaration); functionDeclaration.setSignatureSymbol(signature); @@ -52356,7 +53722,7 @@ var TypeScript; } var funcDecl = this.semanticInfoChain.getASTForDecl(functionDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList), functionTypeSymbol, signature); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), functionTypeSymbol, signature); var typeParameters = functionDeclaration.getTypeParameters(); var typeParameter; @@ -52365,7 +53731,7 @@ var TypeScript; typeParameter = signature.findTypeParameter(typeParameters[i].name); if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); signature.addTypeParameter(typeParameter); } else { @@ -52377,15 +53743,7 @@ var TypeScript; typeParameters[i].setSymbol(typeParameter); } - functionTypeSymbol.addCallSignature(signature); - - var otherDecls = this.findDeclsInContext(functionDeclaration, functionDeclaration.kind, false); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } + functionTypeSymbol.appendCallSignature(signature); }; PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { @@ -52393,10 +53751,10 @@ var TypeScript; var declFlags = functionExpressionDeclaration.flags; var ast = this.semanticInfoChain.getASTForDecl(functionExpressionDeclaration); - var parameters = ast.kind() === 219 /* SimpleArrowFunctionExpression */ ? TypeScript.Parameters.fromIdentifier(ast.identifier) : TypeScript.Parameters.fromParameterList(TypeScript.getParameterList(ast)); + var parameters = ast.kind() === 219 /* SimpleArrowFunctionExpression */ ? TypeScript.ASTHelpers.parametersFromIdentifier(ast.identifier) : TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(ast)); var funcExpAST = ast; - var functionName = declKind == 131072 /* FunctionExpression */ ? functionExpressionDeclaration.getFunctionExpressionName() : functionExpressionDeclaration.name; + var functionName = declKind === 131072 /* FunctionExpression */ ? functionExpressionDeclaration.getFunctionExpressionName() : functionExpressionDeclaration.name; var functionSymbol = new TypeScript.PullSymbol(functionName, declKind); var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); functionTypeSymbol.setFunctionSymbol(functionSymbol); @@ -52414,7 +53772,7 @@ var TypeScript; this.semanticInfoChain.setSymbolForAST(funcExpAST, functionSymbol); - var signature = new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, true); if (parameters.lastParameterIsRest()) { signature.hasVarArgs = true; @@ -52427,7 +53785,7 @@ var TypeScript; typeParameter = signature.findTypeParameter(typeParameters[i].name); if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); signature.addTypeParameter(typeParameter); } else { @@ -52444,7 +53802,7 @@ var TypeScript; this.bindParameterSymbols(funcExpAST, parameters, functionTypeSymbol, signature); - functionTypeSymbol.addCallSignature(signature); + functionTypeSymbol.appendCallSignature(signature); }; PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { @@ -52459,7 +53817,7 @@ var TypeScript; this.semanticInfoChain.setSymbolForAST(funcTypeAST, functionTypeSymbol); var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); if (TypeScript.lastParameterIsRest(funcTypeAST.parameterList)) { signature.hasVarArgs = true; @@ -52472,7 +53830,7 @@ var TypeScript; typeParameter = signature.findTypeParameter(typeParameters[i].name); if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); signature.addTypeParameter(typeParameter); } else { @@ -52487,9 +53845,9 @@ var TypeScript; signature.addDeclaration(functionTypeDeclaration); functionTypeDeclaration.setSignatureSymbol(signature); - this.bindParameterSymbols(funcTypeAST, TypeScript.Parameters.fromParameterList(funcTypeAST.parameterList), functionTypeSymbol, signature); + this.bindParameterSymbols(funcTypeAST, TypeScript.ASTHelpers.parametersFromParameterList(funcTypeAST.parameterList), functionTypeSymbol, signature); - functionTypeSymbol.addCallSignature(signature); + functionTypeSymbol.appendCallSignature(signature); }; PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { @@ -52518,7 +53876,7 @@ var TypeScript; methodSymbol = parent.findMember(methodName, false); if (methodSymbol && (methodSymbol.kind !== 65536 /* Method */ || (!isSignature && !methodSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { - this.semanticInfoChain.addDiagnosticFromAST(methodAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [methodDeclaration.getDisplayName()]); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(methodAST, methodDeclaration.getDisplayName(), methodSymbol.getDeclarations()[0].ast()); methodSymbol = null; } @@ -52558,9 +53916,9 @@ var TypeScript; var sigKind = 1048576 /* CallSignature */; - var signature = isSignature ? new TypeScript.PullSignatureSymbol(sigKind) : new TypeScript.PullDefinitionSignatureSymbol(sigKind); + var signature = new TypeScript.PullSignatureSymbol(sigKind, !isSignature); - var parameterList = TypeScript.getParameterList(methodAST); + var parameterList = TypeScript.ASTHelpers.getParameterList(methodAST); if (TypeScript.lastParameterIsRest(parameterList)) { signature.hasVarArgs = true; } @@ -52577,7 +53935,7 @@ var TypeScript; typeParameter = signature.findTypeParameter(typeParameterName); if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName, true); + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName); signature.addTypeParameter(typeParameter); } else { this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); @@ -52591,29 +53949,22 @@ var TypeScript; methodDeclaration.setSignatureSymbol(signature); var funcDecl = this.semanticInfoChain.getASTForDecl(methodDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(TypeScript.getParameterList(funcDecl)), methodTypeSymbol, signature); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), methodTypeSymbol, signature); - methodTypeSymbol.addCallSignature(signature); - - var otherDecls = this.findDeclsInContext(methodDeclaration, methodDeclaration.kind, false); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(signature, methodTypeSymbol.getOwnCallSignatures()); + methodTypeSymbol.insertCallSignatureAtIndex(signature, signatureIndex); }; - PullSymbolBinder.prototype.bindStaticPrototypePropertyOfClass = function (classTypeSymbol, constructorTypeSymbol) { + PullSymbolBinder.prototype.bindStaticPrototypePropertyOfClass = function (classAST, classTypeSymbol, constructorTypeSymbol) { var prototypeStr = "prototype"; var prototypeSymbol = constructorTypeSymbol.findMember(prototypeStr, false); if (prototypeSymbol && !prototypeSymbol.getIsSynthesized()) { - this.semanticInfoChain.addDiagnostic(TypeScript.diagnosticFromDecl(prototypeSymbol.getDeclarations()[0], TypeScript.DiagnosticCode.Duplicate_identifier_0, [prototypeSymbol.getDisplayName()])); + this.semanticInfoChain.addDiagnostic(TypeScript.PullHelpers.diagnosticFromDecl(prototypeSymbol.getDeclarations()[0], TypeScript.DiagnosticCode.Duplicate_identifier_0, [prototypeSymbol.getDisplayName()])); } if (!prototypeSymbol || !prototypeSymbol.getIsSynthesized()) { - var prototypeDecl = new TypeScript.PullSynthesizedDecl(prototypeStr, prototypeStr, 4096 /* Property */, 4 /* Public */ | 16 /* Static */, constructorTypeSymbol.getDeclarations()[0], classTypeSymbol.getDeclarations()[0].getSpan(), this.semanticInfoChain); + var prototypeDecl = new TypeScript.PullSynthesizedDecl(prototypeStr, prototypeStr, 4096 /* Property */, 4 /* Public */ | 16 /* Static */, constructorTypeSymbol.getDeclarations()[0], this.semanticInfoChain); prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); prototypeSymbol.setIsSynthesized(); @@ -52679,36 +54030,20 @@ var TypeScript; constructorSymbol.setIsSynthesized(false); this.semanticInfoChain.setSymbolForAST(constructorAST, constructorSymbol); - var constructSignature = isSignature ? new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */) : new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */); - + var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */, !isSignature); constructSignature.returnType = parent; + constructSignature.addTypeParametersFromReturnType(); constructSignature.addDeclaration(constructorDeclaration); constructorDeclaration.setSignatureSymbol(constructSignature); - this.bindParameterSymbols(constructorAST, TypeScript.Parameters.fromParameterList(constructorAST.parameterList), constructorTypeSymbol, constructSignature); + this.bindParameterSymbols(constructorAST, TypeScript.ASTHelpers.parametersFromParameterList(constructorAST.callSignature.parameterList), constructorTypeSymbol, constructSignature); - var typeParameters = constructorTypeSymbol.getTypeParameters(); - - for (var i = 0; i < typeParameters.length; i++) { - constructSignature.addTypeParameter(typeParameters[i]); - } - - if (TypeScript.lastParameterIsRest(constructorAST.parameterList)) { + if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { constructSignature.hasVarArgs = true; } - constructorTypeSymbol.addConstructSignature(constructSignature); - - var otherDecls = this.findDeclsInContext(constructorDeclaration, constructorDeclaration.kind, false); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } - - this.bindStaticPrototypePropertyOfClass(parent, constructorTypeSymbol); + constructorTypeSymbol.appendConstructSignature(constructSignature); }; PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { @@ -52728,7 +54063,7 @@ var TypeScript; typeParameter = constructSignature.findTypeParameter(typeParameters[i].name); if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); constructSignature.addTypeParameter(typeParameter); } else { @@ -52744,11 +54079,12 @@ var TypeScript; constructSignatureDeclaration.setSignatureSymbol(constructSignature); var funcDecl = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(TypeScript.getParameterList(funcDecl)), null, constructSignature); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), null, constructSignature); this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration), constructSignature); - parent.addConstructSignature(constructSignature); + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(constructSignature, parent.getOwnConstructSignatures()); + parent.insertConstructSignatureAtIndex(constructSignature, signatureIndex); }; PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { @@ -52768,7 +54104,7 @@ var TypeScript; typeParameter = callSignature.findTypeParameter(typeParameters[i].name); if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); callSignature.addTypeParameter(typeParameter); } else { @@ -52784,11 +54120,12 @@ var TypeScript; callSignatureDeclaration.setSignatureSymbol(callSignature); var funcDecl = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(funcDecl.parameterList), null, callSignature); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), null, callSignature); this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(callSignatureDeclaration), callSignature); - parent.addCallSignature(callSignature); + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(callSignature, parent.getOwnCallSignatures()); + parent.insertCallSignatureAtIndex(callSignature, signatureIndex); }; PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { @@ -52798,7 +54135,7 @@ var TypeScript; indexSignatureDeclaration.setSignatureSymbol(indexSignature); var funcDecl = this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameter(funcDecl.parameter), null, indexSignature); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter), null, indexSignature); this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration), indexSignature); @@ -52838,7 +54175,7 @@ var TypeScript; if (accessorSymbol) { if (!accessorSymbol.isAccessor()) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [getAccessorDeclaration.getDisplayName()]); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, getAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); accessorSymbol = null; } else { getterSymbol = accessorSymbol.getGetter(); @@ -52885,14 +54222,14 @@ var TypeScript; parent.addMember(accessorSymbol); } - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); signature.addDeclaration(getAccessorDeclaration); getAccessorDeclaration.setSignatureSymbol(signature); - this.bindParameterSymbols(funcDeclAST, TypeScript.Parameters.fromParameterList(funcDeclAST.parameterList), getterTypeSymbol, signature); + this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), getterTypeSymbol, signature); - getterTypeSymbol.addCallSignature(signature); + getterTypeSymbol.appendCallSignature(signature); }; PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { @@ -52926,7 +54263,7 @@ var TypeScript; if (accessorSymbol) { if (!accessorSymbol.isAccessor()) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [setAccessorDeclaration.getDisplayName()]); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, setAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); accessorSymbol = null; } else { setterSymbol = accessorSymbol.getSetter(); @@ -52973,25 +54310,63 @@ var TypeScript; parent.addMember(accessorSymbol); } - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); signature.addDeclaration(setAccessorDeclaration); setAccessorDeclaration.setSignatureSymbol(signature); - this.bindParameterSymbols(funcDeclAST, TypeScript.Parameters.fromParameterList(funcDeclAST.parameterList), setterTypeSymbol, signature); + this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), setterTypeSymbol, signature); - setterTypeSymbol.addCallSignature(signature); + setterTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.getDeclsToBind = function (decl) { + var decls; + switch (decl.kind) { + case 64 /* Enum */: + case 32 /* DynamicModule */: + case 4 /* Container */: + case 16 /* Interface */: + decls = this.findDeclsInContext(decl, decl.kind, true); + break; + + case 512 /* Variable */: + case 16384 /* Function */: + case 65536 /* Method */: + case 32768 /* ConstructorMethod */: + decls = this.findDeclsInContext(decl, decl.kind, false); + break; + + default: + decls = [decl]; + } + TypeScript.Debug.assert(decls && decls.length > 0); + TypeScript.Debug.assert(TypeScript.ArrayUtilities.contains(decls, decl)); + return decls; + }; + + PullSymbolBinder.prototype.shouldBindDeclaration = function (decl) { + return !decl.hasBeenBound() && this.declsBeingBound.indexOf(decl.declID) < 0; }; PullSymbolBinder.prototype.bindDeclToPullSymbol = function (decl) { - if (decl.hasBeenBound()) { - return; + if (this.shouldBindDeclaration(decl)) { + this.bindAllDeclsToPullSymbol(decl); } + }; - if (this.declsBeingBound.indexOf(decl.declID) >= 0) { - return; + PullSymbolBinder.prototype.bindAllDeclsToPullSymbol = function (askedDecl) { + var allDecls = this.getDeclsToBind(askedDecl); + for (var i = 0; i < allDecls.length; i++) { + var decl = allDecls[i]; + + if (this.shouldBindDeclaration(decl)) { + this.bindSingleDeclToPullSymbol(decl); + } } + }; + PullSymbolBinder.prototype.bindSingleDeclToPullSymbol = function (decl) { this.declsBeingBound.push(decl.declID); switch (decl.kind) { @@ -53110,6 +54485,25 @@ var TypeScript; var TypeScript; (function (TypeScript) { (function (PullHelpers) { + function diagnosticFromDecl(decl, diagnosticKey, _arguments, additionalLocations) { + if (typeof _arguments === "undefined") { _arguments = null; } + if (typeof additionalLocations === "undefined") { additionalLocations = null; } + var ast = decl.ast(); + return decl.semanticInfoChain.diagnosticFromAST(ast, diagnosticKey, _arguments, additionalLocations); + } + PullHelpers.diagnosticFromDecl = diagnosticFromDecl; + + function resolveDeclaredSymbolToUseType(symbol) { + if (symbol.isSignature()) { + if (!symbol.returnType) { + symbol._resolveDeclaredSymbol(); + } + } else if (!symbol.type) { + symbol._resolveDeclaredSymbol(); + } + } + PullHelpers.resolveDeclaredSymbolToUseType = resolveDeclaredSymbolToUseType; + function getSignatureForFuncDecl(functionDecl) { var funcDecl = functionDecl.ast(); var funcSymbol = functionDecl.getSymbol(); @@ -53180,7 +54574,7 @@ var TypeScript; PullHelpers.symbolIsEnum = symbolIsEnum; function symbolIsModule(symbol) { - return symbol && (symbol.kind == 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); + return symbol && (symbol.kind === 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); } PullHelpers.symbolIsModule = symbolIsModule; @@ -53209,7 +54603,7 @@ var TypeScript; b = b.referencedTypeSymbol; } - return a == b; + return a === b; } PullHelpers.typeSymbolsAreIdentical = typeSymbolsAreIdentical; @@ -53217,7 +54611,7 @@ var TypeScript; var rootType = type.getRootSymbol(); while (true) { - if (type == rootType) { + if (type === rootType) { return type; } @@ -53235,7 +54629,7 @@ var TypeScript; return true; } - if (containerKind == 33554432 /* ConstructorType */ && !symbol.anyDeclHasFlag(16 /* Static */)) { + if (containerKind === 33554432 /* ConstructorType */ && !symbol.anyDeclHasFlag(16 /* Static */ | 1 /* Exported */)) { return true; } } @@ -53243,9 +54637,300 @@ var TypeScript; return false; } PullHelpers.isSymbolLocal = isSymbolLocal; + + function isExportedSymbolInClodule(symbol) { + var container = symbol.getContainer(); + return container && container.kind === 33554432 /* ConstructorType */ && symbolIsModule(container) && symbol.anyDeclHasFlag(1 /* Exported */); + } + PullHelpers.isExportedSymbolInClodule = isExportedSymbolInClodule; + + + + function walkSignatureSymbol(signatureSymbol, walker) { + var continueWalk = true; + var parameters = signatureSymbol.parameters; + if (parameters) { + for (var i = 0; continueWalk && i < parameters.length; i++) { + continueWalk = walker.signatureParameterWalk(parameters[i]); + } + } + + if (continueWalk) { + continueWalk = walker.signatureReturnTypeWalk(signatureSymbol.returnType); + } + + return continueWalk; + } + + function walkPullTypeSymbolStructure(typeSymbol, walker) { + var continueWalk = true; + + var members = typeSymbol.getMembers(); + for (var i = 0; continueWalk && i < members.length; i++) { + continueWalk = walker.memberSymbolWalk(members[i]); + } + + if (continueWalk) { + var callSigantures = typeSymbol.getCallSignatures(); + for (var i = 0; continueWalk && i < callSigantures.length; i++) { + continueWalk = walker.callSignatureWalk(callSigantures[i]); + if (continueWalk) { + continueWalk = walkSignatureSymbol(callSigantures[i], walker); + } + } + } + + if (continueWalk) { + var constructSignatures = typeSymbol.getConstructSignatures(); + for (var i = 0; continueWalk && i < constructSignatures.length; i++) { + continueWalk = walker.constructSignatureWalk(constructSignatures[i]); + if (continueWalk) { + continueWalk = walkSignatureSymbol(constructSignatures[i], walker); + } + } + } + + if (continueWalk) { + var indexSignatures = typeSymbol.getIndexSignatures(); + for (var i = 0; continueWalk && i < indexSignatures.length; i++) { + continueWalk = walker.indexSignatureWalk(indexSignatures[i]); + if (continueWalk) { + continueWalk = walkSignatureSymbol(indexSignatures[i], walker); + } + } + } + } + PullHelpers.walkPullTypeSymbolStructure = walkPullTypeSymbolStructure; + + var OtherPullDeclsWalker = (function () { + function OtherPullDeclsWalker() { + this.currentlyWalkingOtherDecls = []; + } + OtherPullDeclsWalker.prototype.walkOtherPullDecls = function (currentDecl, otherDecls, callBack) { + if (otherDecls) { + var isAlreadyWalkingOtherDecl = TypeScript.ArrayUtilities.any(this.currentlyWalkingOtherDecls, function (inWalkingOtherDecl) { + return TypeScript.ArrayUtilities.contains(otherDecls, inWalkingOtherDecl); + }); + + if (!isAlreadyWalkingOtherDecl) { + this.currentlyWalkingOtherDecls.push(currentDecl); + for (var i = 0; i < otherDecls.length; i++) { + if (otherDecls[i] !== currentDecl) { + callBack(otherDecls[i]); + } + } + var currentlyWalkingOtherDeclsDecl = this.currentlyWalkingOtherDecls.pop(); + TypeScript.Debug.assert(currentlyWalkingOtherDeclsDecl == currentDecl); + } + } + }; + return OtherPullDeclsWalker; + })(); + PullHelpers.OtherPullDeclsWalker = OtherPullDeclsWalker; })(TypeScript.PullHelpers || (TypeScript.PullHelpers = {})); var PullHelpers = TypeScript.PullHelpers; })(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var WrapsTypeParameterCache = (function () { + function WrapsTypeParameterCache() { + this._wrapsTypeParameterCache = TypeScript.BitVector.getBitVector(true); + } + WrapsTypeParameterCache.prototype.getWrapsTypeParameter = function (typeParameterArgumentMap) { + var mapHasTypeParameterNotCached = false; + for (var typeParameterID in typeParameterArgumentMap) { + if (typeParameterArgumentMap.hasOwnProperty(typeParameterID)) { + var cachedValue = this._wrapsTypeParameterCache.valueAt(typeParameterID); + if (cachedValue) { + return typeParameterID; + } + mapHasTypeParameterNotCached = mapHasTypeParameterNotCached || cachedValue === undefined; + } + } + + if (!mapHasTypeParameterNotCached) { + return 0; + } + + return undefined; + }; + + WrapsTypeParameterCache.prototype.setWrapsTypeParameter = function (typeParameterArgumentMap, wrappingTypeParameterID) { + if (wrappingTypeParameterID) { + this._wrapsTypeParameterCache.setValueAt(wrappingTypeParameterID, true); + } else { + for (var typeParameterID in typeParameterArgumentMap) { + if (typeParameterArgumentMap.hasOwnProperty(typeParameterID)) { + this._wrapsTypeParameterCache.setValueAt(typeParameterID, false); + } + } + } + }; + return WrapsTypeParameterCache; + })(); + TypeScript.WrapsTypeParameterCache = WrapsTypeParameterCache; + + (function (PullInstantiationHelpers) { + var MutableTypeArgumentMap = (function () { + function MutableTypeArgumentMap(typeParameterArgumentMap) { + this.typeParameterArgumentMap = typeParameterArgumentMap; + this.createdDuplicateTypeArgumentMap = false; + } + MutableTypeArgumentMap.prototype.ensureTypeArgumentCopy = function () { + if (!this.createdDuplicateTypeArgumentMap) { + var passedInTypeArgumentMap = this.typeParameterArgumentMap; + this.typeParameterArgumentMap = []; + for (var typeParameterID in passedInTypeArgumentMap) { + if (passedInTypeArgumentMap.hasOwnProperty(typeParameterID)) { + this.typeParameterArgumentMap[typeParameterID] = passedInTypeArgumentMap[typeParameterID]; + } + } + this.createdDuplicateTypeArgumentMap = true; + } + }; + return MutableTypeArgumentMap; + })(); + PullInstantiationHelpers.MutableTypeArgumentMap = MutableTypeArgumentMap; + + function instantiateTypeArgument(resolver, symbol, mutableTypeParameterMap) { + if (symbol.getIsSpecialized()) { + var rootTypeArgumentMap = symbol.getTypeParameterArgumentMap(); + var newTypeArgumentMap = []; + var allowedTypeParameters = symbol.getAllowedToReferenceTypeParameters(); + for (var i = 0; i < allowedTypeParameters.length; i++) { + var typeParameterID = allowedTypeParameters[i].pullSymbolID; + var typeArg = rootTypeArgumentMap[typeParameterID]; + if (typeArg) { + newTypeArgumentMap[typeParameterID] = resolver.instantiateType(typeArg, mutableTypeParameterMap.typeParameterArgumentMap); + } + } + + for (var i = 0; i < allowedTypeParameters.length; i++) { + var typeParameterID = allowedTypeParameters[i].pullSymbolID; + if (newTypeArgumentMap[typeParameterID] && mutableTypeParameterMap.typeParameterArgumentMap[typeParameterID] != newTypeArgumentMap[typeParameterID]) { + mutableTypeParameterMap.ensureTypeArgumentCopy(); + mutableTypeParameterMap.typeParameterArgumentMap[typeParameterID] = newTypeArgumentMap[typeParameterID]; + } + } + } + } + PullInstantiationHelpers.instantiateTypeArgument = instantiateTypeArgument; + + function cleanUpTypeArgumentMap(symbol, mutableTypeArgumentMap) { + var allowedToReferenceTypeParameters = symbol.getAllowedToReferenceTypeParameters(); + for (var typeParameterID in mutableTypeArgumentMap.typeParameterArgumentMap) { + if (mutableTypeArgumentMap.typeParameterArgumentMap.hasOwnProperty(typeParameterID)) { + if (!TypeScript.ArrayUtilities.any(allowedToReferenceTypeParameters, function (typeParameter) { + return typeParameter.pullSymbolID == typeParameterID; + })) { + mutableTypeArgumentMap.ensureTypeArgumentCopy(); + delete mutableTypeArgumentMap.typeParameterArgumentMap[typeParameterID]; + } + } + } + } + PullInstantiationHelpers.cleanUpTypeArgumentMap = cleanUpTypeArgumentMap; + + function getAllowedToReferenceTypeParametersFromDecl(decl) { + var allowedToReferenceTypeParameters = []; + + var allowedToUseDeclTypeParameters = false; + var getTypeParametersFromParentDecl = false; + + switch (decl.kind) { + case 65536 /* Method */: + if (TypeScript.hasFlag(decl.flags, 16 /* Static */)) { + allowedToUseDeclTypeParameters = true; + break; + } + + case 16777216 /* FunctionType */: + case 33554432 /* ConstructorType */: + case 2097152 /* ConstructSignature */: + case 1048576 /* CallSignature */: + case 131072 /* FunctionExpression */: + case 16384 /* Function */: + allowedToUseDeclTypeParameters = true; + getTypeParametersFromParentDecl = true; + break; + + case 4096 /* Property */: + if (TypeScript.hasFlag(decl.flags, 16 /* Static */)) { + break; + } + + case 2048 /* Parameter */: + case 262144 /* GetAccessor */: + case 524288 /* SetAccessor */: + case 32768 /* ConstructorMethod */: + case 4194304 /* IndexSignature */: + case 8388608 /* ObjectType */: + case 256 /* ObjectLiteral */: + case 8192 /* TypeParameter */: + getTypeParametersFromParentDecl = true; + break; + + case 8 /* Class */: + case 16 /* Interface */: + allowedToUseDeclTypeParameters = true; + break; + } + + if (getTypeParametersFromParentDecl) { + allowedToReferenceTypeParameters = allowedToReferenceTypeParameters.concat(getAllowedToReferenceTypeParametersFromDecl(decl.getParentDecl())); + } + + if (allowedToUseDeclTypeParameters) { + var typeParameterDecls = decl.getTypeParameters(); + for (var i = 0; i < typeParameterDecls.length; i++) { + allowedToReferenceTypeParameters.push(typeParameterDecls[i].getSymbol()); + } + } + + return allowedToReferenceTypeParameters; + } + PullInstantiationHelpers.getAllowedToReferenceTypeParametersFromDecl = getAllowedToReferenceTypeParametersFromDecl; + + function createTypeParameterArgumentMap(typeParameters, typeArguments) { + return updateTypeParameterArgumentMap(typeParameters, typeArguments, {}); + } + PullInstantiationHelpers.createTypeParameterArgumentMap = createTypeParameterArgumentMap; + + function updateTypeParameterArgumentMap(typeParameters, typeArguments, typeParameterArgumentMap) { + for (var i = 0; i < typeParameters.length; i++) { + typeParameterArgumentMap[typeParameters[i].getRootSymbol().pullSymbolID] = typeArguments[i]; + } + return typeParameterArgumentMap; + } + PullInstantiationHelpers.updateTypeParameterArgumentMap = updateTypeParameterArgumentMap; + + function updateMutableTypeParameterArgumentMap(typeParameters, typeArguments, mutableMap) { + for (var i = 0; i < typeParameters.length; i++) { + var typeParameterId = typeParameters[i].getRootSymbol().pullSymbolID; + if (mutableMap.typeParameterArgumentMap[typeParameterId] !== typeArguments[i]) { + mutableMap.ensureTypeArgumentCopy(); + mutableMap.typeParameterArgumentMap[typeParameterId] = typeArguments[i]; + } + } + } + PullInstantiationHelpers.updateMutableTypeParameterArgumentMap = updateMutableTypeParameterArgumentMap; + + function twoTypesAreInstantiationsOfSameNamedGenericType(type1, type2) { + var type1IsGeneric = type1.isGeneric() && type1.getTypeArguments() !== null; + var type2IsGeneric = type2.isGeneric() && type2.getTypeArguments() !== null; + + if (type1IsGeneric && type2IsGeneric) { + var type1Root = TypeScript.PullHelpers.getRootType(type1); + var type2Root = TypeScript.PullHelpers.getRootType(type2); + return type1Root === type2Root; + } + + return false; + } + PullInstantiationHelpers.twoTypesAreInstantiationsOfSameNamedGenericType = twoTypesAreInstantiationsOfSameNamedGenericType; + })(TypeScript.PullInstantiationHelpers || (TypeScript.PullInstantiationHelpers = {})); + var PullInstantiationHelpers = TypeScript.PullInstantiationHelpers; +})(TypeScript || (TypeScript = {})); if (Error) Error.stackTraceLimit = 1000; @@ -53286,10 +54971,19 @@ var TypeScript; TypeScript.ioHostCreateDirectoryStructureTime = 0; TypeScript.ioHostWriteFileTime = 0; + (function (EmitOutputResult) { + EmitOutputResult[EmitOutputResult["Succeeded"] = 0] = "Succeeded"; + EmitOutputResult[EmitOutputResult["FailedBecauseOfSyntaxErrors"] = 1] = "FailedBecauseOfSyntaxErrors"; + EmitOutputResult[EmitOutputResult["FailedBecauseOfCompilerOptionsErrors"] = 2] = "FailedBecauseOfCompilerOptionsErrors"; + EmitOutputResult[EmitOutputResult["FailedToGenerateDeclarationsBecauseOfSemanticErrors"] = 3] = "FailedToGenerateDeclarationsBecauseOfSemanticErrors"; + })(TypeScript.EmitOutputResult || (TypeScript.EmitOutputResult = {})); + var EmitOutputResult = TypeScript.EmitOutputResult; + var EmitOutput = (function () { - function EmitOutput() { + function EmitOutput(emitOutputResult) { + if (typeof emitOutputResult === "undefined") { emitOutputResult = 0 /* Succeeded */; } this.outputFiles = []; - this.diagnostics = []; + this.emitOutputResult = emitOutputResult; } return EmitOutput; })(); @@ -53391,17 +55085,6 @@ var TypeScript; this.semanticInfoChain.removeDocument(fileName); }; - TypeScriptCompiler.prototype._isDynamicModuleCompilation = function () { - var fileNames = this.fileNames(); - for (var i = 0, n = fileNames.length; i < n; i++) { - var document = this.getDocument(fileNames[i]); - if (!document.isDeclareFile() && document.isExternalModule()) { - return true; - } - } - return false; - }; - TypeScriptCompiler.prototype.mapOutputFileName = function (document, emitOptions, extensionChanger) { if (document.emitToOwnOutputFile()) { var updatedFileName = document.fileName; @@ -53501,7 +55184,7 @@ var TypeScript; var emitOptions = new TypeScript.EmitOptions(this, resolvePath); if (emitOptions.diagnostic()) { - emitOutput.diagnostics.push(emitOptions.diagnostic()); + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; return emitOutput; } @@ -53533,7 +55216,7 @@ var TypeScript; var emitOptions = new TypeScript.EmitOptions(this, resolvePath); if (emitOptions.diagnostic()) { - emitOutput.diagnostics.push(emitOptions.diagnostic()); + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; return emitOutput; } @@ -53549,6 +55232,12 @@ var TypeScript; } }; + TypeScriptCompiler.prototype.canEmitDeclarations = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + var document = this.getDocument(fileName); + return this._shouldEmitDeclarations(document); + }; + TypeScriptCompiler.mapToFileNameExtension = function (extension, fileName, wholeFileNameReplaced) { if (wholeFileNameReplaced) { return fileName; @@ -53609,7 +55298,7 @@ var TypeScript; var emitOptions = new TypeScript.EmitOptions(this, resolvePath); if (emitOptions.diagnostic()) { - emitOutput.diagnostics.push(emitOptions.diagnostic()); + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; return emitOutput; } @@ -53640,7 +55329,7 @@ var TypeScript; var emitOptions = new TypeScript.EmitOptions(this, resolvePath); if (emitOptions.diagnostic()) { - emitOutput.diagnostics.push(emitOptions.diagnostic()); + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; return emitOutput; } @@ -53715,6 +55404,15 @@ var TypeScript; return errors; }; + TypeScriptCompiler.prototype.getCompilerOptionsDiagnostics = function () { + var emitOptions = new TypeScript.EmitOptions(this, null); + var emitDiagnostic = emitOptions.diagnostic(); + if (emitDiagnostic) { + return [emitDiagnostic]; + } + return TypeScript.sentinelEmptyArray; + }; + TypeScriptCompiler.prototype.resolveAllFiles = function () { var fileNames = this.fileNames(); for (var i = 0, n = fileNames.length; i < n; i++) { @@ -53791,8 +55489,6 @@ var TypeScript; var contextualType = null; if ((i + 2 < n) && callExpression.argumentList === path[i + 1] && callExpression.argumentList.arguments === path[i + 2]) { - var arguments = callExpression.argumentList.arguments; - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); if (isNew) { resolver.resolveObjectCreationExpression(callExpression, resolutionContext, callResolutionResults); @@ -53822,7 +55518,7 @@ var TypeScript; } } - resolutionContext.pushContextualType(contextualType, false, null); + resolutionContext.pushNewContextualType(contextualType); } break; @@ -53835,7 +55531,7 @@ var TypeScript; contextualType = currentContextualType.getElementType(); } - resolutionContext.pushContextualType(contextualType, false, null); + resolutionContext.pushNewContextualType(contextualType); } break; @@ -53862,7 +55558,7 @@ var TypeScript; } } - resolutionContext.pushContextualType(contextualType, false, null); + resolutionContext.pushNewContextualType(contextualType); } } @@ -53881,7 +55577,25 @@ var TypeScript; } } - resolutionContext.pushContextualType(contextualType, false, null); + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 220 /* CastExpression */: + var castExpression = current; + if (!(i + 1 < n && path[i + 1] === castExpression.type)) { + if (propagateContextualTypes) { + var contextualType = null; + var typeSymbol = resolver.resolveAST(castExpression, inContextuallyTypedAssignment, resolutionContext).type; + + if (typeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = typeSymbol; + } + + resolutionContext.pushNewContextualType(contextualType); + } } break; @@ -53892,7 +55606,7 @@ var TypeScript; var contextualType = null; if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */)) { - var typeAnnotation = TypeScript.getType(enclosingDeclAST); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); if (typeAnnotation) { var returnTypeSymbol = resolver.resolveTypeReference(typeAnnotation, resolutionContext); if (returnTypeSymbol) { @@ -53902,7 +55616,8 @@ var TypeScript; } else { var currentContextualType = resolutionContext.getContextualType(); if (currentContextualType && currentContextualType.isFunction()) { - var currentContextualTypeSignatureSymbol = currentContextualType.getDeclarations()[0].getSignatureSymbol(); + var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); + var currentContextualTypeSignatureSymbol = contextualSignatures[0]; var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; if (currentContextualTypeReturnTypeSymbol) { inContextuallyTypedAssignment = true; @@ -53912,7 +55627,7 @@ var TypeScript; } } - resolutionContext.pushContextualType(contextualType, false, null); + resolutionContext.pushNewContextualType(contextualType); } break; @@ -53927,6 +55642,10 @@ var TypeScript; case 163 /* WithStatement */: inWithBlock = true; break; + + case 146 /* Block */: + inContextuallyTypedAssignment = false; + break; } var decl = this.semanticInfoChain.getDeclForAST(current); @@ -53968,7 +55687,7 @@ var TypeScript; contextualType = varSymbol.type; } - resolutionContext.pushContextualType(contextualType, false, null); + resolutionContext.pushNewContextualType(contextualType); if (init) { resolver.resolveAST(init, inContextuallyTypedAssignment, resolutionContext); @@ -53999,7 +55718,7 @@ var TypeScript; var symbol = resolver.resolveAST(ast, context.inContextuallyTypedAssignment, context.resolutionContext); if (!symbol) { - TypeScript.Debug.assert(ast.kind() == 120 /* SourceUnit */, "No symbol was found for ast and ast was not source unit. Ast Kind: " + TypeScript.SyntaxKind[ast.kind()]); + TypeScript.Debug.assert(ast.kind() === 120 /* SourceUnit */, "No symbol was found for ast and ast was not source unit. Ast Kind: " + TypeScript.SyntaxKind[ast.kind()]); return null; } @@ -54140,6 +55859,32 @@ var TypeScript; TypeScriptCompiler.prototype.topLevelDecl = function (fileName) { return this.semanticInfoChain.topLevelDecl(fileName); }; + + TypeScriptCompiler.getLocationText = function (location) { + return location.fileName() + "(" + (location.line() + 1) + "," + (location.character() + 1) + ")"; + }; + + TypeScriptCompiler.getFullDiagnosticText = function (diagnostic) { + var result = ""; + if (diagnostic.fileName()) { + result += this.getLocationText(diagnostic) + ": "; + } + + result += diagnostic.message(); + + var additionalLocations = diagnostic.additionalLocations(); + if (additionalLocations.length > 0) { + result += " " + TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Additional_locations, null) + TypeScript.Environment.newLine; + + for (var i = 0, n = additionalLocations.length; i < n; i++) { + result += "\t" + this.getLocationText(additionalLocations[i]) + TypeScript.Environment.newLine; + } + } else { + result += TypeScript.Environment.newLine; + } + + return result; + }; return TypeScriptCompiler; })(); TypeScript.TypeScriptCompiler = TypeScriptCompiler; @@ -54220,11 +55965,11 @@ var TypeScript; case 0 /* Syntax */: case 1 /* Semantics */: - return this.index == this.fileNames.length; + return this.index === this.fileNames.length; case 3 /* Emit */: case 4 /* DeclarationEmit */: - return this.index == (this.fileNames.length + 1); + return this.index === (this.fileNames.length + 1); } return false; @@ -54344,10 +56089,10 @@ var TypeScript; function compareDataObjects(dst, src) { for (var e in dst) { - if (typeof dst[e] == "object") { + if (typeof dst[e] === "object") { if (!compareDataObjects(dst[e], src[e])) return false; - } else if (typeof dst[e] != "function") { + } else if (typeof dst[e] !== "function") { if (dst[e] !== src[e]) return false; } @@ -54373,7 +56118,7 @@ var TypeScript; this.referencedTypeSymbol = referencedTypeSymbol; this.isResolved = true; - TypeScript.Debug.assert(referencedTypeSymbol != null, "Type root symbol may not be null"); + TypeScript.Debug.assert(referencedTypeSymbol !== null, "Type root symbol may not be null"); this.setRootSymbol(referencedTypeSymbol); @@ -54540,11 +56285,17 @@ var TypeScript; return this.referencedTypeSymbol.getTypeArgumentsOrTypeParameters(); }; - PullTypeReferenceSymbol.prototype.addCallSignature = function (callSignature) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addCallSignature"); + PullTypeReferenceSymbol.prototype.appendCallSignature = function (callSignature) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": appendCallSignature"); }; - PullTypeReferenceSymbol.prototype.addConstructSignature = function (constructSignature) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addConstructSignature"); + PullTypeReferenceSymbol.prototype.insertCallSignatureAtIndex = function (callSignature, index) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": insertCallSignatureAtIndex"); + }; + PullTypeReferenceSymbol.prototype.appendConstructSignature = function (callSignature) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": appendConstructSignature"); + }; + PullTypeReferenceSymbol.prototype.insertConstructSignatureAtIndex = function (callSignature, index) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": insertConstructSignatureAtIndex"); }; PullTypeReferenceSymbol.prototype.addIndexSignature = function (indexSignature) { TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addIndexSignature"); @@ -54604,11 +56355,6 @@ var TypeScript; return this.referencedTypeSymbol.getTypesThatExplicitlyImplementThisType(); }; - PullTypeReferenceSymbol.prototype.hasBase = function (potentialBase, visited) { - if (typeof visited === "undefined") { visited = []; } - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasBase(potentialBase, visited); - }; PullTypeReferenceSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { this.ensureReferencedTypeIsResolved(); return this.referencedTypeSymbol.isValidBaseKind(baseType, isExtendedType); @@ -54653,25 +56399,26 @@ var TypeScript; TypeScript.nSpecializationsCreated = 0; TypeScript.nSpecializedSignaturesCreated = 0; + TypeScript.nSpecializedTypeParameterCreated = 0; var PullInstantiatedTypeReferenceSymbol = (function (_super) { __extends(PullInstantiatedTypeReferenceSymbol, _super); - function PullInstantiatedTypeReferenceSymbol(referencedTypeSymbol, _typeParameterArgumentMap) { + function PullInstantiatedTypeReferenceSymbol(referencedTypeSymbol, _typeParameterArgumentMap, isInstanceReferenceType) { _super.call(this, referencedTypeSymbol); this.referencedTypeSymbol = referencedTypeSymbol; this._typeParameterArgumentMap = _typeParameterArgumentMap; + this.isInstanceReferenceType = isInstanceReferenceType; this._instantiatedMembers = null; this._allInstantiatedMemberNameCache = null; this._instantiatedMemberNameCache = TypeScript.createIntrinsicsObject(); this._instantiatedCallSignatures = null; this._instantiatedConstructSignatures = null; this._instantiatedIndexSignatures = null; - this._typeArgumentReferences = null; + this._typeArgumentReferences = undefined; this._instantiatedConstructorMethod = null; this._instantiatedAssociatedContainerType = null; this._isArray = undefined; - this.isInstanceReferenceType = false; - this._generativeTypeClassification = 0 /* Unknown */; + this._generativeTypeClassification = []; TypeScript.nSpecializationsCreated++; } @@ -54680,72 +56427,43 @@ var TypeScript; }; PullInstantiatedTypeReferenceSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { - if (this._generativeTypeClassification == 0 /* Unknown */) { - var typeParameters = enclosingType.getTypeParameters(); - var typeReferenceTypeArguments = this.getRootSymbol().getTypeArguments(); - var referenceTypeArgument = null; - - if (!typeReferenceTypeArguments) { - var typeParametersMap = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeParametersMap[typeParameters[i].pullSymbolID] = typeParameters[i]; - } - - var rootThis = TypeScript.PullHelpers.getRootType(this); - var wrapsSomeTypeParameters = rootThis.wrapsSomeTypeParameter(typeParametersMap); - - if (wrapsSomeTypeParameters && this.wrapsSomeNestedTypeIntoInfiniteExpansion(enclosingType)) { - this._generativeTypeClassification = 3 /* InfinitelyExpanding */; - } else if (wrapsSomeTypeParameters) { - this._generativeTypeClassification = 1 /* Open */; - } else { - this._generativeTypeClassification = 2 /* Closed */; - } - } else { - var i = 0; - - while (i < typeReferenceTypeArguments.length) { - referenceTypeArgument = typeReferenceTypeArguments[i].getRootSymbol(); - - if (referenceTypeArgument.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - break; - } - - i++; - } - - if (i == typeParameters.length) { - this._generativeTypeClassification = 2 /* Closed */; - } - - if (this._generativeTypeClassification == 0 /* Unknown */) { - var i = 0; - - while ((this._generativeTypeClassification == 0 /* Unknown */) && (i < typeReferenceTypeArguments.length)) { - for (var j = 0; j < typeParameters.length; j++) { - if (typeParameters[j] == typeReferenceTypeArguments[i]) { - this._generativeTypeClassification = 1 /* Open */; - break; - } - } - - i++; - } - - if (this._generativeTypeClassification != 1 /* Open */) { - this._generativeTypeClassification = 3 /* InfinitelyExpanding */; - } - } - } + if (!this.isNamedTypeSymbol()) { + return 0 /* Unknown */; } - return this._generativeTypeClassification; + var generativeTypeClassification = this._generativeTypeClassification[enclosingType.pullSymbolID] || 0 /* Unknown */; + if (generativeTypeClassification === 0 /* Unknown */) { + var typeParameters = enclosingType.getTypeParameters(); + var enclosingTypeParameterMap = []; + for (var i = 0; i < typeParameters.length; i++) { + enclosingTypeParameterMap[typeParameters[i].pullSymbolID] = typeParameters[i]; + } + + var typeArguments = this.getTypeArguments(); + for (var i = 0; i < typeArguments.length; i++) { + if (typeArguments[i].wrapsSomeTypeParameter(enclosingTypeParameterMap, true)) { + generativeTypeClassification = 1 /* Open */; + break; + } + } + + if (generativeTypeClassification === 1 /* Open */) { + if (this.wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference(enclosingType)) { + generativeTypeClassification = 3 /* InfinitelyExpanding */; + } + } else { + generativeTypeClassification = 2 /* Closed */; + } + + this._generativeTypeClassification[enclosingType.pullSymbolID] = generativeTypeClassification; + } + + return generativeTypeClassification; }; PullInstantiatedTypeReferenceSymbol.prototype.isArrayNamedTypeReference = function () { if (this._isArray === undefined) { - this._isArray = this.getRootSymbol().isArrayNamedTypeReference() || (this.getRootSymbol() == this._getResolver().getArrayNamedType()); + this._isArray = this.getRootSymbol().isArrayNamedTypeReference() || (this.getRootSymbol() === this._getResolver().getArrayNamedType()); } return this._isArray; }; @@ -54756,12 +56474,7 @@ var TypeScript; } var typeArguments = this.getTypeArguments(); - - if (typeArguments != null) { - return typeArguments[0]; - } - - return null; + return typeArguments ? typeArguments[0] : null; }; PullInstantiatedTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { @@ -54774,130 +56487,47 @@ var TypeScript; return this.referencedTypeSymbol; }; - PullInstantiatedTypeReferenceSymbol.create = function (resolver, type, typeParameterArgumentMap, instantiateFunctionTypeParameters) { - if (typeof instantiateFunctionTypeParameters === "undefined") { instantiateFunctionTypeParameters = false; } + PullInstantiatedTypeReferenceSymbol.create = function (resolver, type, typeParameterArgumentMap) { TypeScript.Debug.assert(resolver); + var mutableTypeParameterMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(typeParameterArgumentMap); + + TypeScript.PullInstantiationHelpers.instantiateTypeArgument(resolver, type, mutableTypeParameterMap); + var rootType = type.getRootSymbol(); - - var reconstructedTypeArgumentList = []; - var typeArguments = type.getTypeArguments(); - var typeParameters = rootType.getTypeParameters(); - - if (type.getIsSpecialized() && typeArguments && typeArguments.length) { - for (var i = 0; i < typeArguments.length; i++) { - reconstructedTypeArgumentList[reconstructedTypeArgumentList.length] = resolver.instantiateType(typeArguments[i], typeParameterArgumentMap, instantiateFunctionTypeParameters); - } - - for (var i = 0; i < typeArguments.length; i++) { - typeParameterArgumentMap[typeArguments[i].pullSymbolID] = reconstructedTypeArgumentList[i]; - } - } else { - var tyArg = null; - - for (var typeParameterID in typeParameterArgumentMap) { - if (typeParameterArgumentMap.hasOwnProperty(typeParameterID)) { - tyArg = typeParameterArgumentMap[typeParameterID]; - - if (tyArg) { - reconstructedTypeArgumentList[reconstructedTypeArgumentList.length] = tyArg; - } - } - } + var instantiation = rootType.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); + if (instantiation) { + return instantiation; } - if (!instantiateFunctionTypeParameters) { - var instantiation = rootType.getSpecialization(reconstructedTypeArgumentList); + TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(type, mutableTypeParameterMap); + typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; - if (instantiation) { - return instantiation; - } - } - - var isReferencedType = (type.kind & 8216 /* SomeInstantiatableType */) != 0; - - if (isReferencedType) { - if (typeParameters && reconstructedTypeArgumentList) { - if (typeParameters.length == reconstructedTypeArgumentList.length) { - for (var i = 0; i < typeParameters.length; i++) { - if (!TypeScript.PullHelpers.typeSymbolsAreIdentical(typeParameters[i], reconstructedTypeArgumentList[i])) { - isReferencedType = false; - break; - } - } - - if (isReferencedType) { - typeParameterArgumentMap = []; - } - } else { - isReferencedType = false; - } - } - } - - var instantiateRoot = isReferencedType; - - if (type.isTypeReference() && type.isGeneric()) { - var initializationMap = []; - - for (var typeParameterID in typeParameterArgumentMap) { - if (typeParameterArgumentMap.hasOwnProperty(typeParameterID)) { - initializationMap[typeParameterID] = typeParameterArgumentMap[typeParameterID]; + var isInstanceReferenceType = (type.kind & 8216 /* SomeInstantiatableType */) != 0; + var resolvedTypeParameterArgumentMap = typeParameterArgumentMap; + if (isInstanceReferenceType) { + var typeParameters = rootType.getTypeParameters(); + for (var i = 0; i < typeParameters.length; i++) { + if (!TypeScript.PullHelpers.typeSymbolsAreIdentical(typeParameters[i], typeParameterArgumentMap[typeParameters[i].pullSymbolID])) { + isInstanceReferenceType = false; + break; } } - var oldMap = typeParameterArgumentMap; - - var outerTypeMap = type._typeParameterArgumentMap; - var innerSubstitution = null; - var outerSubstitution = null; - var canRelatePreInstantiatedTypeParametersToRootTypeParameters = true; - - for (var typeParameterID in outerTypeMap) { - if (outerTypeMap.hasOwnProperty(typeParameterID)) { - outerSubstitution = outerTypeMap[typeParameterID]; - innerSubstitution = typeParameterArgumentMap[outerSubstitution.pullSymbolID]; - - if (innerSubstitution && (!outerSubstitution.isTypeParameter() || !outerTypeMap[innerSubstitution.pullSymbolID] || !outerTypeMap[outerTypeMap[typeParameterID].pullSymbolID] || (outerTypeMap[outerTypeMap[typeParameterID].pullSymbolID] == outerSubstitution))) { - initializationMap[typeParameterID] = typeParameterArgumentMap[outerTypeMap[typeParameterID].pullSymbolID]; - - if (!outerSubstitution.isTypeParameter()) { - canRelatePreInstantiatedTypeParametersToRootTypeParameters = false; - } - } else { - canRelatePreInstantiatedTypeParametersToRootTypeParameters = false; - } - } - } - - if (canRelatePreInstantiatedTypeParametersToRootTypeParameters && typeParameters.length) { + if (isInstanceReferenceType) { typeParameterArgumentMap = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameterArgumentMap[typeParameters[i].pullSymbolID] = initializationMap[typeParameters[i].pullSymbolID]; - } - - instantiateRoot = true; - } else { - typeParameterArgumentMap = initializationMap; } } - instantiation = new PullInstantiatedTypeReferenceSymbol(instantiateRoot ? rootType : type, typeParameterArgumentMap); + instantiation = new PullInstantiatedTypeReferenceSymbol(rootType, typeParameterArgumentMap, isInstanceReferenceType); - if (!instantiateFunctionTypeParameters) { - rootType.addSpecialization(instantiation, reconstructedTypeArgumentList); - } - - if (isReferencedType) { - instantiation.isInstanceReferenceType = true; - } + rootType.addSpecialization(instantiation, resolvedTypeParameterArgumentMap); return instantiation; }; PullInstantiatedTypeReferenceSymbol.prototype.isGeneric = function () { - return !!this.referencedTypeSymbol.getTypeParameters().length; + return this.getRootSymbol().isGeneric(); }; PullInstantiatedTypeReferenceSymbol.prototype.getTypeParameterArgumentMap = function () { @@ -54909,7 +56539,7 @@ var TypeScript; return this.getTypeParameters(); } - if (!this._typeArgumentReferences) { + if (this._typeArgumentReferences === undefined) { var typeParameters = this.referencedTypeSymbol.getTypeParameters(); if (typeParameters.length) { @@ -54929,6 +56559,8 @@ var TypeScript; } this._typeArgumentReferences = typeArguments; + } else { + this._typeArgumentReferences = null; } } @@ -54939,6 +56571,21 @@ var TypeScript; return this.getTypeArguments(); }; + PullInstantiatedTypeReferenceSymbol.prototype.populateInstantiatedMemberFromReferencedMember = function (referencedMember) { + var instantiatedMember; + TypeScript.PullHelpers.resolveDeclaredSymbolToUseType(referencedMember); + + if (!referencedMember.type.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + instantiatedMember = referencedMember; + } else { + instantiatedMember = new TypeScript.PullSymbol(referencedMember.name, referencedMember.kind); + instantiatedMember.setRootSymbol(referencedMember); + instantiatedMember.type = this._getResolver().instantiateType(referencedMember.type, this._typeParameterArgumentMap); + instantiatedMember.isOptional = referencedMember.isOptional; + } + this._instantiatedMemberNameCache[instantiatedMember.name] = instantiatedMember; + }; + PullInstantiatedTypeReferenceSymbol.prototype.getMembers = function () { this.ensureReferencedTypeIsResolved(); @@ -54959,21 +56606,10 @@ var TypeScript; this._getResolver().resolveDeclaredSymbol(referencedMember); if (!this._instantiatedMemberNameCache[referencedMember.name]) { - if (!referencedMember.type.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - instantiatedMember = referencedMember; - } else { - instantiatedMember = new TypeScript.PullSymbol(referencedMember.name, referencedMember.kind); - instantiatedMember.setRootSymbol(referencedMember); - instantiatedMember.type = this._getResolver().instantiateType(referencedMember.type, this._typeParameterArgumentMap); - instantiatedMember.isOptional = referencedMember.isOptional; - } - - this._instantiatedMemberNameCache[instantiatedMember.name] = instantiatedMember; - } else { - instantiatedMember = this._instantiatedMemberNameCache[referencedMember.name]; + this.populateInstantiatedMemberFromReferencedMember(referencedMember); } - this._instantiatedMembers[this._instantiatedMembers.length] = instantiatedMember; + this._instantiatedMembers[this._instantiatedMembers.length] = this._instantiatedMemberNameCache[referencedMember.name]; } } @@ -54994,16 +56630,8 @@ var TypeScript; var referencedMemberSymbol = this.referencedTypeSymbol.findMember(name, lookInParent); if (referencedMemberSymbol) { - memberSymbol = new TypeScript.PullSymbol(referencedMemberSymbol.name, referencedMemberSymbol.kind); - memberSymbol.setRootSymbol(referencedMemberSymbol); - - this._getResolver().resolveDeclaredSymbol(referencedMemberSymbol); - - memberSymbol.type = this._getResolver().instantiateType(referencedMemberSymbol.type, this._typeParameterArgumentMap); - - memberSymbol.isOptional = referencedMemberSymbol.isOptional; - - this._instantiatedMemberNameCache[memberSymbol.name] = memberSymbol; + this.populateInstantiatedMemberFromReferencedMember(referencedMemberSymbol); + memberSymbol = this._instantiatedMemberNameCache[name]; } else { memberSymbol = null; } @@ -55070,6 +56698,9 @@ var TypeScript; if (!this._instantiatedConstructorMethod) { var referencedConstructorMethod = this.referencedTypeSymbol.getConstructorMethod(); this._instantiatedConstructorMethod = new TypeScript.PullSymbol(referencedConstructorMethod.name, referencedConstructorMethod.kind); + this._instantiatedConstructorMethod.setRootSymbol(referencedConstructorMethod); + this._instantiatedConstructorMethod.setResolved(); + this._instantiatedConstructorMethod.type = PullInstantiatedTypeReferenceSymbol.create(this._getResolver(), referencedConstructorMethod.type, this._typeParameterArgumentMap); } @@ -55175,14 +56806,79 @@ var TypeScript; return this._instantiatedIndexSignatures; }; - - PullInstantiatedTypeReferenceSymbol.prototype.hasBase = function (potentialBase, visited) { - if (typeof visited === "undefined") { visited = []; } - return this.referencedTypeSymbol.hasBase(potentialBase, visited); - }; return PullInstantiatedTypeReferenceSymbol; })(PullTypeReferenceSymbol); TypeScript.PullInstantiatedTypeReferenceSymbol = PullInstantiatedTypeReferenceSymbol; + + var PullInstantiatedSignatureSymbol = (function (_super) { + __extends(PullInstantiatedSignatureSymbol, _super); + function PullInstantiatedSignatureSymbol(rootSignature, _typeParameterArgumentMap) { + _super.call(this, rootSignature.kind, rootSignature.isDefinition()); + this._typeParameterArgumentMap = _typeParameterArgumentMap; + this.setRootSymbol(rootSignature); + TypeScript.nSpecializedSignaturesCreated++; + + rootSignature.addSpecialization(this, _typeParameterArgumentMap); + } + PullInstantiatedSignatureSymbol.prototype.getTypeParameterArgumentMap = function () { + return this._typeParameterArgumentMap; + }; + + PullInstantiatedSignatureSymbol.prototype.getIsSpecialized = function () { + return true; + }; + + PullInstantiatedSignatureSymbol.prototype._getResolver = function () { + return this.getRootSymbol()._getResolver(); + }; + + PullInstantiatedSignatureSymbol.prototype.getTypeParameters = function () { + var _this = this; + if (!this._typeParameters) { + var rootSymbol = this.getRootSymbol(); + var typeParameters = rootSymbol.getTypeParameters(); + var hasInstantiatedTypeParametersOfThisSignature = TypeScript.ArrayUtilities.all(typeParameters, function (typeParameter) { + return _this._typeParameterArgumentMap[typeParameter.pullSymbolID] !== undefined; + }); + + if (!hasInstantiatedTypeParametersOfThisSignature && typeParameters.length) { + this._typeParameters = []; + for (var i = 0; i < typeParameters.length; i++) { + this._typeParameters[this._typeParameters.length] = this._getResolver().instantiateTypeParameter(typeParameters[i], this._typeParameterArgumentMap); + } + } else { + this._typeParameters = TypeScript.sentinelEmptyArray; + } + } + + return this._typeParameters; + }; + + PullInstantiatedSignatureSymbol.prototype.getAllowedToReferenceTypeParameters = function () { + var rootSymbol = this.getRootSymbol(); + return rootSymbol.getAllowedToReferenceTypeParameters(); + }; + return PullInstantiatedSignatureSymbol; + })(TypeScript.PullSignatureSymbol); + TypeScript.PullInstantiatedSignatureSymbol = PullInstantiatedSignatureSymbol; + + var PullInstantiatedTypeParameterSymbol = (function (_super) { + __extends(PullInstantiatedTypeParameterSymbol, _super); + function PullInstantiatedTypeParameterSymbol(rootTypeParameter, constraintType) { + _super.call(this, rootTypeParameter.name); + TypeScript.nSpecializedTypeParameterCreated++; + + this.setRootSymbol(rootTypeParameter); + this.setConstraint(constraintType); + + rootTypeParameter.addSpecialization(this, [constraintType]); + } + PullInstantiatedTypeParameterSymbol.prototype._getResolver = function () { + return this.getRootSymbol()._getResolver(); + }; + return PullInstantiatedTypeParameterSymbol; + })(TypeScript.PullTypeParameterSymbol); + TypeScript.PullInstantiatedTypeParameterSymbol = PullInstantiatedTypeParameterSymbol; })(TypeScript || (TypeScript = {})); var TypeScript; (function (TypeScript) { @@ -55421,8 +57117,8 @@ var TypeScript; TypeScript.Debug.assert(start === 0); var bod = this.visitSyntaxList(node.moduleElements); - - var result = new TypeScript.SourceUnit(bod, this.fileName); + var comments = this.convertTokenLeadingComments(node.endOfFileToken, TypeScript.Syntax.childOffset(node, node.endOfFileToken)); + var result = new TypeScript.SourceUnit(bod, comments, this.fileName); this.setSpanExplicit(result, start, start + node.fullWidth()); return result; @@ -55999,17 +57695,17 @@ var TypeScript; this.movePast(node.openParenToken); - var arguments = this.visitSeparatedSyntaxList(node.arguments); + var _arguments = this.visitSeparatedSyntaxList(node.arguments); if (node.arguments.fullWidth() === 0 && node.closeParenToken.fullWidth() === 0) { var openParenTokenEnd = start + node.openParenToken.leadingTriviaWidth() + node.openParenToken.width(); - this.setSpanExplicit(arguments, openParenTokenEnd, openParenTokenEnd + node.openParenToken.trailingTriviaWidth()); + this.setSpanExplicit(_arguments, openParenTokenEnd, openParenTokenEnd + node.openParenToken.trailingTriviaWidth()); } var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); this.movePast(node.closeParenToken); - var result = new TypeScript.ArgumentList(typeArguments, arguments, closeParenToken); + var result = new TypeScript.ArgumentList(typeArguments, _arguments, closeParenToken); this.setSpan(result, start, node); return result; @@ -56230,14 +57926,14 @@ var TypeScript; SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { var start = this.position; - this.moveTo(node, node.parameterList); - var parameters = this.visitParameterList(node.parameterList); + this.moveTo(node, node.callSignature); + var callSignature = this.visitCallSignature(node.callSignature); var block = node.block ? node.block.accept(this) : null; this.movePast(node.semicolonToken); - var result = new TypeScript.ConstructorDeclaration(parameters, block); + var result = new TypeScript.ConstructorDeclaration(callSignature, block); this.setCommentsAndSpan(result, start, node); return result; @@ -57648,6 +59344,10 @@ var TypeScript; return commentArrayStructuralEquals(this.preComments(), ast.preComments(), includingPosition) && commentArrayStructuralEquals(this.postComments(), ast.postComments(), includingPosition); }; + + AST.prototype.isExpression = function () { + return false; + }; return AST; })(); TypeScript.AST = AST; @@ -57749,9 +59449,10 @@ var TypeScript; var SourceUnit = (function (_super) { __extends(SourceUnit, _super); - function SourceUnit(moduleElements, _fileName) { + function SourceUnit(moduleElements, endOfFileTokenLeadingComments, _fileName) { _super.call(this); this.moduleElements = moduleElements; + this.endOfFileTokenLeadingComments = endOfFileTokenLeadingComments; this._fileName = _fileName; moduleElements && (moduleElements.parent = this); } @@ -57800,6 +59501,10 @@ var TypeScript; Identifier.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._text === ast._text; }; + + Identifier.prototype.isExpression = function () { + return true; + }; return Identifier; })(AST); TypeScript.Identifier = Identifier; @@ -57827,6 +59532,10 @@ var TypeScript; LiteralExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition); }; + + LiteralExpression.prototype.isExpression = function () { + return true; + }; return LiteralExpression; })(AST); TypeScript.LiteralExpression = LiteralExpression; @@ -57853,6 +59562,10 @@ var TypeScript; ThisExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition); }; + + ThisExpression.prototype.isExpression = function () { + return true; + }; return ThisExpression; })(AST); TypeScript.ThisExpression = ThisExpression; @@ -57879,6 +59592,10 @@ var TypeScript; SuperExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition); }; + + SuperExpression.prototype.isExpression = function () { + return true; + }; return SuperExpression; })(AST); TypeScript.SuperExpression = SuperExpression; @@ -57908,6 +59625,10 @@ var TypeScript; NumericLiteral.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && (this._value === ast._value || (isNaN(this._value) && isNaN(ast._value))) && this._text === ast._text; }; + + NumericLiteral.prototype.isExpression = function () { + return true; + }; return NumericLiteral; })(AST); TypeScript.NumericLiteral = NumericLiteral; @@ -57930,6 +59651,10 @@ var TypeScript; RegularExpressionLiteral.prototype.kind = function () { return 12 /* RegularExpressionLiteral */; }; + + RegularExpressionLiteral.prototype.isExpression = function () { + return true; + }; return RegularExpressionLiteral; })(AST); TypeScript.RegularExpressionLiteral = RegularExpressionLiteral; @@ -57956,6 +59681,10 @@ var TypeScript; StringLiteral.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._text === ast._text; }; + + StringLiteral.prototype.isExpression = function () { + return true; + }; return StringLiteral; })(AST); TypeScript.StringLiteral = StringLiteral; @@ -58279,6 +60008,10 @@ var TypeScript; PrefixUnaryExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.operand, ast.operand, includingPosition); }; + + PrefixUnaryExpression.prototype.isExpression = function () { + return true; + }; return PrefixUnaryExpression; })(AST); TypeScript.PrefixUnaryExpression = PrefixUnaryExpression; @@ -58297,6 +60030,10 @@ var TypeScript; ArrayLiteralExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expressions, ast.expressions, includingPosition); }; + + ArrayLiteralExpression.prototype.isExpression = function () { + return true; + }; return ArrayLiteralExpression; })(AST); TypeScript.ArrayLiteralExpression = ArrayLiteralExpression; @@ -58313,6 +60050,10 @@ var TypeScript; OmittedExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition); }; + + OmittedExpression.prototype.isExpression = function () { + return true; + }; return OmittedExpression; })(AST); TypeScript.OmittedExpression = OmittedExpression; @@ -58332,6 +60073,10 @@ var TypeScript; ParenthesizedExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); }; + + ParenthesizedExpression.prototype.isExpression = function () { + return true; + }; return ParenthesizedExpression; })(AST); TypeScript.ParenthesizedExpression = ParenthesizedExpression; @@ -58350,6 +60095,10 @@ var TypeScript; SimpleArrowFunctionExpression.prototype.kind = function () { return 219 /* SimpleArrowFunctionExpression */; }; + + SimpleArrowFunctionExpression.prototype.isExpression = function () { + return true; + }; return SimpleArrowFunctionExpression; })(AST); TypeScript.SimpleArrowFunctionExpression = SimpleArrowFunctionExpression; @@ -58368,6 +60117,10 @@ var TypeScript; ParenthesizedArrowFunctionExpression.prototype.kind = function () { return 218 /* ParenthesizedArrowFunctionExpression */; }; + + ParenthesizedArrowFunctionExpression.prototype.isExpression = function () { + return true; + }; return ParenthesizedArrowFunctionExpression; })(AST); TypeScript.ParenthesizedArrowFunctionExpression = ParenthesizedArrowFunctionExpression; @@ -58588,6 +60341,10 @@ var TypeScript; MemberAccessExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.name, ast.name, includingPosition); }; + + MemberAccessExpression.prototype.isExpression = function () { + return true; + }; return MemberAccessExpression; })(AST); TypeScript.MemberAccessExpression = MemberAccessExpression; @@ -58607,6 +60364,10 @@ var TypeScript; PostfixUnaryExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.operand, ast.operand, includingPosition); }; + + PostfixUnaryExpression.prototype.isExpression = function () { + return true; + }; return PostfixUnaryExpression; })(AST); TypeScript.PostfixUnaryExpression = PostfixUnaryExpression; @@ -58627,6 +60388,10 @@ var TypeScript; ElementAccessExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.argumentExpression, ast.argumentExpression, includingPosition); }; + + ElementAccessExpression.prototype.isExpression = function () { + return true; + }; return ElementAccessExpression; })(AST); TypeScript.ElementAccessExpression = ElementAccessExpression; @@ -58647,19 +60412,24 @@ var TypeScript; InvocationExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.argumentList, ast.argumentList, includingPosition); }; + + InvocationExpression.prototype.isExpression = function () { + return true; + }; return InvocationExpression; })(AST); TypeScript.InvocationExpression = InvocationExpression; var ArgumentList = (function (_super) { __extends(ArgumentList, _super); - function ArgumentList(typeArgumentList, arguments, closeParenToken) { + function ArgumentList(typeArgumentList, _arguments, closeParenToken) { _super.call(this); this.typeArgumentList = typeArgumentList; - this.arguments = arguments; this.closeParenToken = closeParenToken; + this.arguments = _arguments; + typeArgumentList && (typeArgumentList.parent = this); - arguments && (arguments.parent = this); + _arguments && (_arguments.parent = this); } ArgumentList.prototype.kind = function () { return 226 /* ArgumentList */; @@ -58685,6 +60455,10 @@ var TypeScript; BinaryExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.left, ast.left, includingPosition) && structuralEquals(this.right, ast.right, includingPosition); }; + + BinaryExpression.prototype.isExpression = function () { + return true; + }; return BinaryExpression; })(AST); TypeScript.BinaryExpression = BinaryExpression; @@ -58707,6 +60481,10 @@ var TypeScript; ConditionalExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.whenTrue, ast.whenTrue, includingPosition) && structuralEquals(this.whenFalse, ast.whenFalse, includingPosition); }; + + ConditionalExpression.prototype.isExpression = function () { + return true; + }; return ConditionalExpression; })(AST); TypeScript.ConditionalExpression = ConditionalExpression; @@ -58887,11 +60665,11 @@ var TypeScript; var ConstructorDeclaration = (function (_super) { __extends(ConstructorDeclaration, _super); - function ConstructorDeclaration(parameterList, block) { + function ConstructorDeclaration(callSignature, block) { _super.call(this); - this.parameterList = parameterList; + this.callSignature = callSignature; this.block = block; - parameterList && (parameterList.parent = this); + callSignature && (callSignature.parent = this); block && (block.parent = this); } ConstructorDeclaration.prototype.kind = function () { @@ -59041,6 +60819,10 @@ var TypeScript; ObjectCreationExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.argumentList, ast.argumentList, includingPosition); }; + + ObjectCreationExpression.prototype.isExpression = function () { + return true; + }; return ObjectCreationExpression; })(AST); TypeScript.ObjectCreationExpression = ObjectCreationExpression; @@ -59277,6 +61059,10 @@ var TypeScript; CastExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.type, ast.type, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); }; + + CastExpression.prototype.isExpression = function () { + return true; + }; return CastExpression; })(AST); TypeScript.CastExpression = CastExpression; @@ -59295,6 +61081,10 @@ var TypeScript; ObjectLiteralExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.propertyAssignments, ast.propertyAssignments, includingPosition); }; + + ObjectLiteralExpression.prototype.isExpression = function () { + return true; + }; return ObjectLiteralExpression; })(AST); TypeScript.ObjectLiteralExpression = ObjectLiteralExpression; @@ -59347,6 +61137,10 @@ var TypeScript; FunctionExpression.prototype.kind = function () { return 222 /* FunctionExpression */; }; + + FunctionExpression.prototype.isExpression = function () { + return true; + }; return FunctionExpression; })(AST); TypeScript.FunctionExpression = FunctionExpression; @@ -59484,6 +61278,10 @@ var TypeScript; TypeOfExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); }; + + TypeOfExpression.prototype.isExpression = function () { + return true; + }; return TypeOfExpression; })(AST); TypeScript.TypeOfExpression = TypeOfExpression; @@ -59502,6 +61300,10 @@ var TypeScript; DeleteExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); }; + + DeleteExpression.prototype.isExpression = function () { + return true; + }; return DeleteExpression; })(AST); TypeScript.DeleteExpression = DeleteExpression; @@ -59520,6 +61322,10 @@ var TypeScript; VoidExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); }; + + VoidExpression.prototype.isExpression = function () { + return true; + }; return VoidExpression; })(AST); TypeScript.VoidExpression = VoidExpression; @@ -59571,17 +61377,6 @@ var TypeScript; return Comment; })(); TypeScript.Comment = Comment; - - function diagnosticFromDecl(decl, diagnosticKey, arguments) { - if (typeof arguments === "undefined") { arguments = null; } - var span = decl.getSpan(); - return new TypeScript.Diagnostic(decl.fileName(), decl.semanticInfoChain().lineMap(decl.fileName()), span.start(), span.length(), diagnosticKey, arguments); - } - TypeScript.diagnosticFromDecl = diagnosticFromDecl; - - function min(a, b) { - return a <= b ? a : b; - } })(TypeScript || (TypeScript = {})); var TypeScript; (function (TypeScript) { @@ -59682,6 +61477,11 @@ var TypeScript; } return { + appendFile: function (path, content) { + var txtFile = fso.OpenTextFile(path, 8, true); + txtFile.Write(content); + txtFile.Close(); + }, readFile: function (path, codepage) { return TypeScript.Environment.readFile(path, codepage); }, @@ -59802,6 +61602,9 @@ var TypeScript; var _module = require('module'); return { + appendFile: function (path, content) { + _fs.appendFileSync(path, content); + }, readFile: function (file, codepage) { return TypeScript.Environment.readFile(file, codepage); }, @@ -60245,10 +62048,38 @@ var TypeScript; return DiagnosticsLogger; })(); + var FileLogger = (function () { + function FileLogger(ioHost) { + this.ioHost = ioHost; + var file = "tsc." + Date.now() + ".log"; + + this.fileName = this.ioHost.resolvePath(file); + } + FileLogger.prototype.information = function () { + return false; + }; + FileLogger.prototype.debug = function () { + return false; + }; + FileLogger.prototype.warning = function () { + return false; + }; + FileLogger.prototype.error = function () { + return false; + }; + FileLogger.prototype.fatal = function () { + return false; + }; + FileLogger.prototype.log = function (s) { + this.ioHost.appendFile(this.fileName, s + '\r\n'); + }; + return FileLogger; + })(); + var BatchCompiler = (function () { function BatchCompiler(ioHost) { this.ioHost = ioHost; - this.compilerVersion = "0.9.5.0"; + this.compilerVersion = "0.9.7.0"; this.inputFiles = []; this.resolvedFiles = []; this.fileNameToSourceFile = new TypeScript.StringHashTable(); @@ -60266,7 +62097,13 @@ var TypeScript; } }; if (this.parseOptions()) { - this.logger = this.compilationSettings.gatherDiagnostics() ? new DiagnosticsLogger(this.ioHost) : new TypeScript.NullLogger(); + if (this.compilationSettings.createFileLog()) { + this.logger = new FileLogger(this.ioHost); + } else if (this.compilationSettings.gatherDiagnostics()) { + this.logger = new DiagnosticsLogger(this.ioHost); + } else { + this.logger = new TypeScript.NullLogger(); + } if (this.compilationSettings.watch()) { this.watchFiles(); @@ -60277,6 +62114,46 @@ var TypeScript; this.compile(); + if (this.compilationSettings.createFileLog()) { + this.logger.log("Compilation settings:"); + this.logger.log(" propagateEnumConstants " + this.compilationSettings.propagateEnumConstants()); + this.logger.log(" removeComments " + this.compilationSettings.removeComments()); + this.logger.log(" watch " + this.compilationSettings.watch()); + this.logger.log(" noResolve " + this.compilationSettings.noResolve()); + this.logger.log(" noImplicitAny " + this.compilationSettings.noImplicitAny()); + this.logger.log(" nolib " + this.compilationSettings.noLib()); + this.logger.log(" target " + this.compilationSettings.codeGenTarget()); + this.logger.log(" module " + this.compilationSettings.moduleGenTarget()); + this.logger.log(" out " + this.compilationSettings.outFileOption()); + this.logger.log(" outDir " + this.compilationSettings.outDirOption()); + this.logger.log(" sourcemap " + this.compilationSettings.mapSourceFiles()); + this.logger.log(" mapRoot " + this.compilationSettings.mapRoot()); + this.logger.log(" sourceroot " + this.compilationSettings.sourceRoot()); + this.logger.log(" declaration " + this.compilationSettings.generateDeclarationFiles()); + this.logger.log(" useCaseSensitiveFileResolution " + this.compilationSettings.useCaseSensitiveFileResolution()); + this.logger.log(" diagnostics " + this.compilationSettings.gatherDiagnostics()); + this.logger.log(" codepage " + this.compilationSettings.codepage()); + + this.logger.log(""); + + this.logger.log("Input files:"); + this.inputFiles.forEach(function (file) { + _this.logger.log(" " + file); + }); + + this.logger.log(""); + + this.logger.log("Resolved Files:"); + this.resolvedFiles.forEach(function (file) { + file.importedFiles.forEach(function (file) { + _this.logger.log(" " + file); + }); + file.referencedFiles.forEach(function (file) { + _this.logger.log(" " + file); + }); + }); + } + if (this.compilationSettings.gatherDiagnostics()) { this.logger.log(""); this.logger.log("File resolution time: " + TypeScript.fileResolutionTime); @@ -60507,6 +62384,7 @@ var TypeScript; }); opts.flag('noResolve', { + experimental: true, usage: { locCode: TypeScript.DiagnosticCode.Skip_resolution_and_preprocessing, args: null @@ -60530,6 +62408,13 @@ var TypeScript; } }); + opts.flag('logFile', { + experimental: true, + set: function () { + mutableSettings.createFileLog = true; + } + }); + opts.option('target', { usage: { locCode: TypeScript.DiagnosticCode.Specify_ECMAScript_target_version_0_default_or_1, @@ -60644,11 +62529,12 @@ var TypeScript; this.inputFiles.push.apply(this.inputFiles, opts.unnamed); - if (this.inputFiles.length === 0 || needsHelp) { + if (shouldPrintVersionOnly) { + opts.printVersion(); + return false; + } else if (this.inputFiles.length === 0 || needsHelp) { opts.printUsage(); return false; - } else if (shouldPrintVersionOnly) { - opts.printVersion(); } return !this.hasErrors; @@ -60853,11 +62739,7 @@ var TypeScript; this.hasErrors = true; } - if (diagnostic.fileName()) { - this.ioHost.stderr.Write(diagnostic.fileName() + "(" + (diagnostic.line() + 1) + "," + (diagnostic.character() + 1) + "): "); - } - - this.ioHost.stderr.WriteLine(diagnostic.message()); + this.ioHost.stderr.Write(TypeScript.TypeScriptCompiler.getFullDiagnosticText(diagnostic)); }; BatchCompiler.prototype.tryWriteOutputFiles = function (outputFiles) { diff --git a/_infrastructure/tests/typescript/0.9.5-beta/typescript.js b/_infrastructure/tests/typescript/0.9.7/typescript.js similarity index 86% rename from _infrastructure/tests/typescript/0.9.5-beta/typescript.js rename to _infrastructure/tests/typescript/0.9.7/typescript.js index 667affcf1..29ed8063a 100644 --- a/_infrastructure/tests/typescript/0.9.5-beta/typescript.js +++ b/_infrastructure/tests/typescript/0.9.7/typescript.js @@ -57,7 +57,7 @@ var TypeScript; Implementations_are_not_allowed_in_ambient_contexts: "Implementations are not allowed in ambient contexts.", declare_modifier_not_allowed_for_code_already_in_an_ambient_context: "'declare' modifier not allowed for code already in an ambient context.", Initializers_are_not_allowed_in_ambient_contexts: "Initializers are not allowed in ambient contexts.", - Parameter_property_declarations_can_only_be_used_in_constructors: "Parameter property declarations can only be used in constructors.", + Parameter_property_declarations_can_only_be_used_in_a_non_ambient_constructor_declaration: "Parameter property declarations can only be used in a non-ambient constructor declaration.", Function_implementation_expected: "Function implementation expected.", Constructor_implementation_expected: "Constructor implementation expected.", Function_overload_name_must_be_0: "Function overload name must be '{0}'.", @@ -97,13 +97,15 @@ var TypeScript; declare_modifier_not_allowed_on_import_declaration: "'declare' modifier not allowed on import declaration.", Function_overload_must_be_static: "Function overload must be static.", Function_overload_must_not_be_static: "Function overload must not be static.", - Parameter_property_declarations_cannot_be_used_in_an_ambient_context: "Parameter property declarations cannot be used in an ambient context.", Parameter_property_declarations_cannot_be_used_in_a_constructor_overload: "Parameter property declarations cannot be used in a constructor overload.", Invalid_reference_directive_syntax: "Invalid 'reference' directive syntax.", Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: "Octal literals are not available when targeting ECMAScript 5 and higher.", Accessors_are_not_allowed_in_ambient_contexts: "Accessors are not allowed in ambient contexts.", _0_modifier_cannot_appear_on_a_constructor_declaration: "'{0}' modifier cannot appear on a constructor declaration.", _0_modifier_cannot_appear_on_a_parameter: "'{0}' modifier cannot appear on a parameter.", + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: "Only a single variable declaration is allowed in a 'for...in' statement.", + Type_parameters_cannot_appear_on_a_constructor_declaration: "Type parameters cannot appear on a constructor declaration.", + Type_annotation_cannot_appear_on_a_constructor_declaration: "Type annotation cannot appear on a constructor declaration.", Duplicate_identifier_0: "Duplicate identifier '{0}'.", The_name_0_does_not_exist_in_the_current_scope: "The name '{0}' does not exist in the current scope.", The_name_0_does_not_refer_to_a_value: "The name '{0}' does not refer to a value.", @@ -199,14 +201,14 @@ var TypeScript; Could_not_find_symbol_0: "Could not find symbol '{0}'.", get_and_set_accessor_must_have_the_same_type: "'get' and 'set' accessor must have the same type.", this_cannot_be_referenced_in_current_location: "'this' cannot be referenced in current location.", - Static_methods_cannot_reference_class_type_parameters: "Static methods cannot reference class type parameters.", + Static_members_cannot_reference_class_type_parameters: "Static members cannot reference class type parameters.", Class_0_is_recursively_referenced_as_a_base_type_of_itself: "Class '{0}' is recursively referenced as a base type of itself.", Interface_0_is_recursively_referenced_as_a_base_type_of_itself: "Interface '{0}' is recursively referenced as a base type of itself.", super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.", super_cannot_be_referenced_in_non_derived_classes: "'super' cannot be referenced in non-derived classes.", A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.", Constructors_for_derived_classes_must_contain_a_super_call: "Constructors for derived classes must contain a 'super' call.", - Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors: "Super calls are not permitted outside constructors or in local functions inside constructors.", + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: "Super calls are not permitted outside constructors or in nested functions inside constructors.", _0_1_is_inaccessible: "'{0}.{1}' is inaccessible.", this_cannot_be_referenced_within_module_bodies: "'this' cannot be referenced within module bodies.", Invalid_expression_types_not_known_to_support_the_addition_operator: "Invalid '+' expression - types not known to support the addition operator.", @@ -219,11 +221,11 @@ var TypeScript; The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number: "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.", The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.", The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.", - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_a_subtype_of_the_Function_interface_type: "The right-hand side of an 'instanceof' expression must be of type 'any' or a subtype of the 'Function' interface type.", + The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.", Setters_cannot_return_a_value: "Setters cannot return a value.", Tried_to_query_type_of_uninitialized_module_0: "Tried to query type of uninitialized module '{0}'.", Tried_to_set_variable_type_to_uninitialized_module_type_0: "Tried to set variable type to uninitialized module type '{0}'.", - Function_0_declared_a_non_void_return_type_but_has_no_return_expression: "Function '{0}' declared a non-void return type, but has no return expression.", + Type_0_does_not_have_type_parameters: "Type '{0}' does not have type parameters.", Getters_must_return_a_value: "Getters must return a value.", Getter_and_setter_accessors_do_not_agree_in_visibility: "Getter and setter accessors do not agree in visibility.", Invalid_left_hand_side_of_assignment_expression: "Invalid left-hand side of assignment expression.", @@ -250,7 +252,7 @@ var TypeScript; Overload_signatures_must_all_be_exported_or_not_exported: "Overload signatures must all be exported or not exported.", Overload_signatures_must_all_be_ambient_or_non_ambient: "Overload signatures must all be ambient or non-ambient.", Overload_signatures_must_all_be_optional_or_required: "Overload signatures must all be optional or required.", - Specialized_overload_signature_is_not_subtype_of_any_non_specialized_signature: "Specialized overload signature is not subtype of any non-specialized signature.", + Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: "Specialized overload signature is not assignable to any non-specialized signature.", this_cannot_be_referenced_in_constructor_arguments: "'this' cannot be referenced in constructor arguments.", Instance_member_cannot_be_accessed_off_a_class: "Instance member cannot be accessed off a class.", Untyped_function_calls_may_not_accept_type_arguments: "Untyped function calls may not accept type arguments.", @@ -261,14 +263,14 @@ var TypeScript; Export_assignments_may_only_be_used_at_the_top_level_of_external_modules: "Export assignments may only be used at the top-level of external modules.", Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules: "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.", Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword: "Only public methods of the base class are accessible via the 'super' keyword.", - Numeric_indexer_type_0_must_be_a_subtype_of_string_indexer_type_1: "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}'.", - Numeric_indexer_type_0_must_be_a_subtype_of_string_indexer_type_1_NL_2: "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}':{NL}{2}", - All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type_0: "All numerically named properties must be subtypes of numeric indexer type '{0}'.", - All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type_0_NL_1: "All numerically named properties must be subtypes of numeric indexer type '{0}':{NL}{1}", - All_named_properties_must_be_subtypes_of_string_indexer_type_0: "All named properties must be subtypes of string indexer type '{0}'.", - All_named_properties_must_be_subtypes_of_string_indexer_type_0_NL_1: "All named properties must be subtypes of string indexer type '{0}':{NL}{1}", + Numeric_indexer_type_0_must_be_assignable_to_string_indexer_type_1: "Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.", + Numeric_indexer_type_0_must_be_assignable_to_string_indexer_type_1_NL_2: "Numeric indexer type '{0}' must be assignable to string indexer type '{1}':{NL}{2}", + All_numerically_named_properties_must_be_assignable_to_numeric_indexer_type_0: "All numerically named properties must be assignable to numeric indexer type '{0}'.", + All_numerically_named_properties_must_be_assignable_to_numeric_indexer_type_0_NL_1: "All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}", + All_named_properties_must_be_assignable_to_string_indexer_type_0: "All named properties must be assignable to string indexer type '{0}'.", + All_named_properties_must_be_assignable_to_string_indexer_type_0_NL_1: "All named properties must be assignable to string indexer type '{0}':{NL}{1}", Generic_type_references_must_include_all_type_arguments: "Generic type references must include all type arguments.", - Default_arguments_are_not_allowed_in_an_overload_parameter: "Default arguments are not allowed in an overload parameter.", + Default_arguments_are_only_allowed_in_implementation: "Default arguments are only allowed in implementation.", Overloads_cannot_differ_only_by_return_type: "Overloads cannot differ only by return type.", Function_expression_declared_a_non_void_return_type_but_has_no_return_expression: "Function expression declared a non-void return type, but has no return expression.", Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules: "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.", @@ -280,7 +282,7 @@ var TypeScript; Exported_import_declaration_0_is_assigned_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.", Exported_import_declaration_0_is_assigned_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.", Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.", - Type_reference_0_in_extends_clause_does_not_reference_constructor_function_for_1: "Type reference '{0}' in extends clause does not reference constructor function for '{1}'.", + Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_1: "Type name '{0}' in extends clause does not reference constructor function for '{1}'.", Internal_module_reference_0_in_import_declaration_does_not_reference_module_instance_for_1: "Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.", Module_0_cannot_merge_with_previous_declaration_of_1_in_a_different_file_2: "Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.", Interface_0_cannot_simultaneously_extend_types_1_and_2_NL_3: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}", @@ -323,6 +325,13 @@ var TypeScript; Type_of_conditional_0_must_be_identical_to_1_or_2: "Type of conditional '{0}' must be identical to '{1}' or '{2}'.", Type_of_conditional_0_must_be_identical_to_1_2_or_3: "Type of conditional '{0}' must be identical to '{1}', '{2}' or '{3}'.", Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.", + Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list.", + Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.", + Parameter_0_cannot_be_referenced_in_its_initializer: "Parameter '{0}' cannot be referenced in its initializer.", + Duplicate_string_index_signature: "Duplicate string index signature.", + Duplicate_number_index_signature: "Duplicate number index signature.", + All_declarations_of_an_interface_must_have_identical_type_parameters: "All declarations of an interface must have identical type parameters.", + Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter: "Expression resolves to variable declaration '_i' that compiler uses to initialize rest parameter.", Type_0_is_missing_property_1_from_type_2: "Type '{0}' is missing property '{1}' from type '{2}'.", Types_of_property_0_of_types_1_and_2_are_incompatible: "Types of property '{0}' of types '{1}' and '{2}' are incompatible.", Types_of_property_0_of_types_1_and_2_are_incompatible_NL_3: "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}", @@ -347,20 +356,23 @@ var TypeScript; Types_of_static_property_0_of_class_1_and_class_2_are_incompatible_NL_3: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}", Type_reference_cannot_refer_to_container_0: "Type reference cannot refer to container '{0}'.", Type_reference_must_refer_to_type: "Type reference must refer to type.", - Enums_with_multiple_declarations_must_provide_an_initializer_for_the_first_enum_element: "Enums with multiple declarations must provide an initializer for the first enum element.", + In_enums_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_the_first_enum_element: "In enums with multiple declarations only one declaration can omit an initializer for the first enum element.", _0_overload_s: " (+ {0} overload(s))", Variable_declaration_cannot_have_the_same_name_as_an_import_declaration: "Variable declaration cannot have the same name as an import declaration.", Signature_expected_0_type_arguments_got_1_instead: "Signature expected {0} type arguments, got {1} instead.", Property_0_defined_as_optional_in_type_1_but_is_required_in_type_2: "Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.", - Types_0_and_1_originating_in_inifinitely_expanding_type_reference_do_not_refer_to_same_named_type: "Types '{0}' and '{1}' originating in inifinitely expanding type reference do not refer to same named type.", - Types_0_and_1_originating_in_inifinitely_expanding_type_reference_have_incompatible_type_arguments: "Types '{0}' and '{1}' originating in inifinitely expanding type reference have incompatible type arguments.", - Types_0_and_1_originating_in_inifinitely_expanding_type_reference_have_incompatible_type_arguments_NL_2: "Types '{0}' and '{1}' originating in inifinitely expanding type reference have incompatible type arguments:{NL}{2}", - Types_of_property_0_of_types_1_and_2_are_not_identical: "Types of property '{0}' of types '{1}' and '{2}' are not identical.", + Types_0_and_1_originating_in_infinitely_expanding_type_reference_do_not_refer_to_same_named_type: "Types '{0}' and '{1}' originating in infinitely expanding type reference do not refer to same named type.", + Types_0_and_1_originating_in_infinitely_expanding_type_reference_have_incompatible_type_arguments: "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments.", + Types_0_and_1_originating_in_infinitely_expanding_type_reference_have_incompatible_type_arguments_NL_2: "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}", + Named_properties_0_of_types_1_and_2_are_not_identical: "Named properties '{0}' of types '{1}' and '{2}' are not identical.", Types_of_string_indexer_of_types_0_and_1_are_not_identical: "Types of string indexer of types '{0}' and '{1}' are not identical.", Types_of_number_indexer_of_types_0_and_1_are_not_identical: "Types of number indexer of types '{0}' and '{1}' are not identical.", - Type_of_number_indexer_in_type_0_is_not_a_subtype_of_string_indexer_type_in_type_1_NL_2: "Type of number indexer in type '{0}' is not a subtype of string indexer type in type '{1}'.{NL}{2}", - Type_of_property_0_in_type_1_is_not_a_subtype_of_string_indexer_type_in_type_2_NL_3: "Type of property '{0}' in type '{1}' is not a subtype of string indexer type in type '{2}'.{NL}{3}", - Type_of_property_0_in_type_1_is_not_a_subtype_of_number_indexer_type_in_type_2_NL_3: "Type of property '{0}' in type '{1}' is not a subtype of number indexer type in type '{2}'.{NL}{3}", + Type_of_number_indexer_in_type_0_is_not_assignable_to_string_indexer_type_in_type_1_NL_2: "Type of number indexer in type '{0}' is not assignable to string indexer type in type '{1}'.{NL}{2}", + Type_of_property_0_in_type_1_is_not_assignable_to_string_indexer_type_in_type_2_NL_3: "Type of property '{0}' in type '{1}' is not assignable to string indexer type in type '{2}'.{NL}{3}", + Type_of_property_0_in_type_1_is_not_assignable_to_number_indexer_type_in_type_2_NL_3: "Type of property '{0}' in type '{1}' is not assignable to number indexer type in type '{2}'.{NL}{3}", + Static_property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Static property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.", + Static_property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Static property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.", + Types_0_and_1_define_static_property_2_as_private: "Types '{0}' and '{1}' define static property '{2}' as private.", Current_host_does_not_support_0_option: "Current host does not support '{0}' option.", ECMAScript_target_version_0_not_supported_Specify_a_valid_target_version_1_default_or_2: "ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'", Module_code_generation_0_not_supported: "Module code generation '{0}' not supported.", @@ -420,6 +432,7 @@ var TypeScript; DIRECTORY: "DIRECTORY", NUMBER: "NUMBER", Specify_the_codepage_to_use_when_opening_source_files: "Specify the codepage to use when opening source files.", + Additional_locations: "Additional locations:", This_version_of_the_Javascript_runtime_does_not_support_the_0_function: "This version of the Javascript runtime does not support the '{0}' function.", Unknown_rule: "Unknown rule.", Invalid_line_number_0: "Invalid line number ({0})", @@ -435,7 +448,9 @@ var TypeScript; Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.", Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.", Array_Literal_implicitly_has_an_any_type_from_widening: "Array Literal implicitly has an 'any' type from widening.", - _0_which_lacks_get_accessor_and_parameter_type_annotation_on_set_accessor_implicitly_has_an_any_type: "'{0}', which lacks 'get' accessor and parameter type annotation on 'set' accessor, implicitly has an 'any' type." + _0_which_lacks_get_accessor_and_parameter_type_annotation_on_set_accessor_implicitly_has_an_any_type: "'{0}', which lacks 'get' accessor and parameter type annotation on 'set' accessor, implicitly has an 'any' type.", + Index_signature_of_object_type_implicitly_has_an_any_type: "Index signature of object type implicitly has an 'any' type.", + Object_literal_s_property_0_implicitly_has_an_any_type_from_widening: "Object literal's property '{0}' implicitly has an 'any' type from widening." }; })(TypeScript || (TypeScript = {})); var TypeScript; @@ -959,20 +974,64 @@ var TypeScript; })(); TypeScript.Debug = Debug; })(TypeScript || (TypeScript = {})); +var __extends = this.__extends || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; var TypeScript; (function (TypeScript) { TypeScript.LocalizedDiagnosticMessages = null; - var Diagnostic = (function () { - function Diagnostic(fileName, lineMap, start, length, diagnosticKey, arguments) { - if (typeof arguments === "undefined") { arguments = null; } - this._diagnosticKey = diagnosticKey; - this._arguments = (arguments && arguments.length > 0) ? arguments : null; + var Location = (function () { + function Location(fileName, lineMap, start, length) { this._fileName = fileName; this._lineMap = lineMap; this._start = start; this._length = length; } + Location.prototype.fileName = function () { + return this._fileName; + }; + + Location.prototype.lineMap = function () { + return this._lineMap; + }; + + Location.prototype.line = function () { + return this._lineMap ? this._lineMap.getLineNumberFromPosition(this.start()) : 0; + }; + + Location.prototype.character = function () { + return this._lineMap ? this._lineMap.getLineAndCharacterFromPosition(this.start()).character() : 0; + }; + + Location.prototype.start = function () { + return this._start; + }; + + Location.prototype.length = function () { + return this._length; + }; + + Location.equals = function (location1, location2) { + return location1._fileName === location2._fileName && location1._start === location2._start && location1._length === location2._length; + }; + return Location; + })(); + TypeScript.Location = Location; + + var Diagnostic = (function (_super) { + __extends(Diagnostic, _super); + function Diagnostic(fileName, lineMap, start, length, diagnosticKey, _arguments, additionalLocations) { + if (typeof _arguments === "undefined") { _arguments = null; } + if (typeof additionalLocations === "undefined") { additionalLocations = null; } + _super.call(this, fileName, lineMap, start, length); + this._diagnosticKey = diagnosticKey; + this._arguments = (_arguments && _arguments.length > 0) ? _arguments : null; + this._additionalLocations = (additionalLocations && additionalLocations.length > 0) ? additionalLocations : null; + } Diagnostic.prototype.toJSON = function (key) { var result = {}; result.start = this.start(); @@ -980,34 +1039,14 @@ var TypeScript; result.diagnosticCode = this._diagnosticKey; - var arguments = this.arguments(); - if (arguments && arguments.length > 0) { - result.arguments = arguments; + var _arguments = this.arguments(); + if (_arguments && _arguments.length > 0) { + result.arguments = _arguments; } return result; }; - Diagnostic.prototype.fileName = function () { - return this._fileName; - }; - - Diagnostic.prototype.line = function () { - return this._lineMap ? this._lineMap.getLineNumberFromPosition(this.start()) : 0; - }; - - Diagnostic.prototype.character = function () { - return this._lineMap ? this._lineMap.getLineAndCharacterFromPosition(this.start()).character() : 0; - }; - - Diagnostic.prototype.start = function () { - return this._start; - }; - - Diagnostic.prototype.length = function () { - return this._length; - }; - Diagnostic.prototype.diagnosticKey = function () { return this._diagnosticKey; }; @@ -1025,11 +1064,11 @@ var TypeScript; }; Diagnostic.prototype.additionalLocations = function () { - return []; + return this._additionalLocations || []; }; Diagnostic.equals = function (diagnostic1, diagnostic2) { - return diagnostic1._fileName === diagnostic2._fileName && diagnostic1._start === diagnostic2._start && diagnostic1._length === diagnostic2._length && diagnostic1._diagnosticKey === diagnostic2._diagnosticKey && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { + return Location.equals(diagnostic1, diagnostic2) && diagnostic1._diagnosticKey === diagnostic2._diagnosticKey && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { return v1 === v2; }); }; @@ -1038,7 +1077,7 @@ var TypeScript; return getDiagnosticInfoFromKey(this.diagnosticKey()); }; return Diagnostic; - })(); + })(Location); TypeScript.Diagnostic = Diagnostic; function newLine() { @@ -1051,7 +1090,7 @@ var TypeScript; var regex = /\{(\d+)\}/g; var match; - while ((match = regex.exec(diagnostic)) != null) { + while (match = regex.exec(diagnostic)) { var val = parseInt(match[1]); if (!isNaN(val) && val > largest) { largest = val; @@ -1216,7 +1255,7 @@ var TypeScript; numberOfCharsLeft -= 2; } - if (numberOfCharsLeft == 1) { + if (numberOfCharsLeft === 1) { h ^= key.charCodeAt(index); h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); } @@ -2252,7 +2291,7 @@ var TypeScript; "code": 1039, "category": 1 /* Error */ }, - "Parameter property declarations can only be used in constructors.": { + "Parameter property declarations can only be used in a non-ambient constructor declaration.": { "code": 1040, "category": 1 /* Error */ }, @@ -2412,10 +2451,6 @@ var TypeScript; "code": 1081, "category": 1 /* Error */ }, - "Parameter property declarations cannot be used in an ambient context.": { - "code": 1082, - "category": 1 /* Error */ - }, "Parameter property declarations cannot be used in a constructor overload.": { "code": 1083, "category": 1 /* Error */ @@ -2440,6 +2475,18 @@ var TypeScript; "code": 1090, "category": 1 /* Error */ }, + "Only a single variable declaration is allowed in a 'for...in' statement.": { + "code": 1091, + "category": 1 /* Error */ + }, + "Type parameters cannot appear on a constructor declaration.": { + "code": 1091, + "category": 1 /* Error */ + }, + "Type annotation cannot appear on a constructor declaration.": { + "code": 1092, + "category": 1 /* Error */ + }, "Duplicate identifier '{0}'.": { "code": 2000, "category": 1 /* Error */ @@ -2820,7 +2867,7 @@ var TypeScript; "code": 2097, "category": 1 /* Error */ }, - "Static methods cannot reference class type parameters.": { + "Static members cannot reference class type parameters.": { "code": 2099, "category": 1 /* Error */ }, @@ -2848,7 +2895,7 @@ var TypeScript; "code": 2105, "category": 1 /* Error */ }, - "Super calls are not permitted outside constructors or in local functions inside constructors.": { + "Super calls are not permitted outside constructors or in nested functions inside constructors.": { "code": 2106, "category": 1 /* Error */ }, @@ -2900,7 +2947,7 @@ var TypeScript; "code": 2120, "category": 1 /* Error */ }, - "The right-hand side of an 'instanceof' expression must be of type 'any' or a subtype of the 'Function' interface type.": { + "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.": { "code": 2121, "category": 1 /* Error */ }, @@ -2916,7 +2963,7 @@ var TypeScript; "code": 2124, "category": 1 /* Error */ }, - "Function '{0}' declared a non-void return type, but has no return expression.": { + "Type '{0}' does not have type parameters.": { "code": 2125, "category": 1 /* Error */ }, @@ -3024,7 +3071,7 @@ var TypeScript; "code": 2153, "category": 1 /* Error */ }, - "Specialized overload signature is not subtype of any non-specialized signature.": { + "Specialized overload signature is not assignable to any non-specialized signature.": { "code": 2154, "category": 1 /* Error */ }, @@ -3068,27 +3115,27 @@ var TypeScript; "code": 2166, "category": 1 /* Error */ }, - "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}'.": { + "Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.": { "code": 2167, "category": 1 /* Error */ }, - "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}':{NL}{2}": { + "Numeric indexer type '{0}' must be assignable to string indexer type '{1}':{NL}{2}": { "code": 2168, "category": 1 /* Error */ }, - "All numerically named properties must be subtypes of numeric indexer type '{0}'.": { + "All numerically named properties must be assignable to numeric indexer type '{0}'.": { "code": 2169, "category": 1 /* Error */ }, - "All numerically named properties must be subtypes of numeric indexer type '{0}':{NL}{1}": { + "All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}": { "code": 2170, "category": 1 /* Error */ }, - "All named properties must be subtypes of string indexer type '{0}'.": { + "All named properties must be assignable to string indexer type '{0}'.": { "code": 2171, "category": 1 /* Error */ }, - "All named properties must be subtypes of string indexer type '{0}':{NL}{1}": { + "All named properties must be assignable to string indexer type '{0}':{NL}{1}": { "code": 2172, "category": 1 /* Error */ }, @@ -3096,7 +3143,7 @@ var TypeScript; "code": 2173, "category": 1 /* Error */ }, - "Default arguments are not allowed in an overload parameter.": { + "Default arguments are only allowed in implementation.": { "code": 2174, "category": 1 /* Error */ }, @@ -3144,7 +3191,7 @@ var TypeScript; "code": 2185, "category": 1 /* Error */ }, - "Type reference '{0}' in extends clause does not reference constructor function for '{1}'.": { + "Type name '{0}' in extends clause does not reference constructor function for '{1}'.": { "code": 2186, "category": 1 /* Error */ }, @@ -3316,6 +3363,34 @@ var TypeScript; "code": 2228, "category": 1 /* Error */ }, + "Constraint of a type parameter cannot reference any type parameter from the same type parameter list.": { + "code": 2229, + "category": 1 /* Error */ + }, + "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.": { + "code": 2230, + "category": 1 /* Error */ + }, + "Parameter '{0}' cannot be referenced in its initializer.": { + "code": 2231, + "category": 1 /* Error */ + }, + "Duplicate string index signature.": { + "code": 2232, + "category": 1 /* Error */ + }, + "Duplicate number index signature.": { + "code": 2233, + "category": 1 /* Error */ + }, + "All declarations of an interface must have identical type parameters.": { + "code": 2234, + "category": 1 /* Error */ + }, + "Expression resolves to variable declaration '_i' that compiler uses to initialize rest parameter.": { + "code": 2235, + "category": 1 /* Error */ + }, "Type '{0}' is missing property '{1}' from type '{2}'.": { "code": 4000, "category": 3 /* NoPrefix */ @@ -3412,7 +3487,7 @@ var TypeScript; "code": 4023, "category": 1 /* Error */ }, - "Enums with multiple declarations must provide an initializer for the first enum element.": { + "In enums with multiple declarations only one declaration can omit an initializer for the first enum element.": { "code": 4024, "category": 1 /* Error */ }, @@ -3432,19 +3507,19 @@ var TypeScript; "code": 4028, "category": 3 /* NoPrefix */ }, - "Types '{0}' and '{1}' originating in inifinitely expanding type reference do not refer to same named type.": { + "Types '{0}' and '{1}' originating in infinitely expanding type reference do not refer to same named type.": { "code": 4029, "category": 3 /* NoPrefix */ }, - "Types '{0}' and '{1}' originating in inifinitely expanding type reference have incompatible type arguments.": { + "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments.": { "code": 4030, "category": 3 /* NoPrefix */ }, - "Types '{0}' and '{1}' originating in inifinitely expanding type reference have incompatible type arguments:{NL}{2}": { + "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}": { "code": 4031, "category": 3 /* NoPrefix */ }, - "Types of property '{0}' of types '{1}' and '{2}' are not identical.": { + "Named properties '{0}' of types '{1}' and '{2}' are not identical.": { "code": 4032, "category": 3 /* NoPrefix */ }, @@ -3456,18 +3531,30 @@ var TypeScript; "code": 4034, "category": 3 /* NoPrefix */ }, - "Type of number indexer in type '{0}' is not a subtype of string indexer type in type '{1}'.{NL}{2}": { + "Type of number indexer in type '{0}' is not assignable to string indexer type in type '{1}'.{NL}{2}": { "code": 4035, "category": 3 /* NoPrefix */ }, - "Type of property '{0}' in type '{1}' is not a subtype of string indexer type in type '{2}'.{NL}{3}": { + "Type of property '{0}' in type '{1}' is not assignable to string indexer type in type '{2}'.{NL}{3}": { "code": 4036, "category": 3 /* NoPrefix */ }, - "Type of property '{0}' in type '{1}' is not a subtype of number indexer type in type '{2}'.{NL}{3}": { + "Type of property '{0}' in type '{1}' is not assignable to number indexer type in type '{2}'.{NL}{3}": { "code": 4037, "category": 3 /* NoPrefix */ }, + "Static property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { + "code": 4038, + "category": 3 /* NoPrefix */ + }, + "Static property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { + "code": 4039, + "category": 3 /* NoPrefix */ + }, + "Types '{0}' and '{1}' define static property '{2}' as private.": { + "code": 4040, + "category": 3 /* NoPrefix */ + }, "Current host does not support '{0}' option.": { "code": 5001, "category": 1 /* Error */ @@ -3704,6 +3791,10 @@ var TypeScript; "code": 6040, "category": 2 /* Message */ }, + "Additional locations:": { + "code": 6041, + "category": 2 /* Message */ + }, "This version of the Javascript runtime does not support the '{0}' function.": { "code": 7000, "category": 1 /* Error */ @@ -3767,6 +3858,14 @@ var TypeScript; "'{0}', which lacks 'get' accessor and parameter type annotation on 'set' accessor, implicitly has an 'any' type.": { "code": 7016, "category": 1 /* Error */ + }, + "Index signature of object type implicitly has an 'any' type.": { + "code": 7017, + "category": 1 /* Error */ + }, + "Object literal's property '{0}' implicitly has an 'any' type from widening.": { + "code": 7018, + "category": 1 /* Error */ } }; })(TypeScript || (TypeScript = {})); @@ -3943,12 +4042,6 @@ var TypeScript; })(TypeScript.LineMap1 || (TypeScript.LineMap1 = {})); var LineMap1 = TypeScript.LineMap1; })(TypeScript || (TypeScript = {})); -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; var TypeScript; (function (TypeScript) { (function (TextFactory) { @@ -6082,40 +6175,47 @@ var TypeScript; var end = this.slidingWindow.absoluteIndex(); var trailingTriviaInfo = this.scanTriviaInfo(diagnostics, true); + var fullEnd = this.slidingWindow.absoluteIndex(); var isVariableWidthKeyword = (kindAndFlags & -2147483648 /* IsVariableWidthKeyword */) !== 0; var kind = kindAndFlags & ~-2147483648 /* IsVariableWidthKeyword */; - var token = this.createToken(fullStart, leadingTriviaInfo, start, kind, end, trailingTriviaInfo, isVariableWidthKeyword); + var token = this.createToken(fullStart, leadingTriviaInfo, start, kind, end, fullEnd, trailingTriviaInfo, isVariableWidthKeyword); return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; }; - Scanner.prototype.createToken = function (fullStart, leadingTriviaInfo, start, kind, end, trailingTriviaInfo, isVariableWidthKeyword) { + Scanner.prototype.createToken = function (fullStart, leadingTriviaInfo, start, kind, end, fullEnd, trailingTriviaInfo, isVariableWidthKeyword) { if (!isVariableWidthKeyword && kind >= 15 /* FirstFixedWidth */) { if (leadingTriviaInfo === 0) { if (trailingTriviaInfo === 0) { return new TypeScript.Syntax.FixedWidthTokenWithNoTrivia(kind); } else { - return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(this.text, fullStart, kind, trailingTriviaInfo); + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); } } else if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(this.text, fullStart, kind, leadingTriviaInfo); + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); } else { - return new TypeScript.Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia(this.text, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo); + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo); } } else { var width = end - start; + + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + if (leadingTriviaInfo === 0) { if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.VariableWidthTokenWithNoTrivia(this.text, fullStart, kind, width); + return new TypeScript.Syntax.VariableWidthTokenWithNoTrivia(fullText, kind); } else { - return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(this.text, fullStart, kind, width, trailingTriviaInfo); + return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); } } else if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(this.text, fullStart, kind, leadingTriviaInfo, width); + return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); } else { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(this.text, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo); + return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo); } } }; @@ -8606,8 +8706,8 @@ var TypeScript; NormalModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { return new TypeScript.ExpressionStatementSyntax(expression, semicolonToken, false); }; - NormalModeFactory.prototype.constructorDeclaration = function (modifiers, constructorKeyword, parameterList, block, semicolonToken) { - return new TypeScript.ConstructorDeclarationSyntax(modifiers, constructorKeyword, parameterList, block, semicolonToken, false); + NormalModeFactory.prototype.constructorDeclaration = function (modifiers, constructorKeyword, callSignature, block, semicolonToken) { + return new TypeScript.ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, false); }; NormalModeFactory.prototype.memberFunctionDeclaration = function (modifiers, propertyName, callSignature, block, semicolonToken) { return new TypeScript.MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, false); @@ -8868,8 +8968,8 @@ var TypeScript; StrictModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { return new TypeScript.ExpressionStatementSyntax(expression, semicolonToken, true); }; - StrictModeFactory.prototype.constructorDeclaration = function (modifiers, constructorKeyword, parameterList, block, semicolonToken) { - return new TypeScript.ConstructorDeclarationSyntax(modifiers, constructorKeyword, parameterList, block, semicolonToken, true); + StrictModeFactory.prototype.constructorDeclaration = function (modifiers, constructorKeyword, callSignature, block, semicolonToken) { + return new TypeScript.ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, true); }; StrictModeFactory.prototype.memberFunctionDeclaration = function (modifiers, propertyName, callSignature, block, semicolonToken) { return new TypeScript.MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, true); @@ -9495,12 +9595,13 @@ var TypeScript; result.parsedInStrictMode = true; } + var thisAsIndexable = this; for (var i = 0, n = this.childCount(); i < n; i++) { var value = this.childAt(i); if (value) { for (var name in this) { - if (value === this[name]) { + if (value === thisAsIndexable[name]) { result[name] = value; break; } @@ -12799,12 +12900,13 @@ var TypeScript; var ArgumentListSyntax = (function (_super) { __extends(ArgumentListSyntax, _super); - function ArgumentListSyntax(typeArgumentList, openParenToken, arguments, closeParenToken, parsedInStrictMode) { + function ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, parsedInStrictMode) { _super.call(this, parsedInStrictMode); this.typeArgumentList = typeArgumentList; this.openParenToken = openParenToken; - this.arguments = arguments; this.closeParenToken = closeParenToken; + + this.arguments = _arguments; } ArgumentListSyntax.prototype.accept = function (visitor) { return visitor.visitArgumentList(this); @@ -14038,11 +14140,11 @@ var TypeScript; var ConstructorDeclarationSyntax = (function (_super) { __extends(ConstructorDeclarationSyntax, _super); - function ConstructorDeclarationSyntax(modifiers, constructorKeyword, parameterList, block, semicolonToken, parsedInStrictMode) { + function ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, parsedInStrictMode) { _super.call(this, parsedInStrictMode); this.modifiers = modifiers; this.constructorKeyword = constructorKeyword; - this.parameterList = parameterList; + this.callSignature = callSignature; this.block = block; this.semicolonToken = semicolonToken; } @@ -14065,7 +14167,7 @@ var TypeScript; case 1: return this.constructorKeyword; case 2: - return this.parameterList; + return this.callSignature; case 3: return this.block; case 4: @@ -14079,20 +14181,20 @@ var TypeScript; return true; }; - ConstructorDeclarationSyntax.prototype.update = function (modifiers, constructorKeyword, parameterList, block, semicolonToken) { - if (this.modifiers === modifiers && this.constructorKeyword === constructorKeyword && this.parameterList === parameterList && this.block === block && this.semicolonToken === semicolonToken) { + ConstructorDeclarationSyntax.prototype.update = function (modifiers, constructorKeyword, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.constructorKeyword === constructorKeyword && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { return this; } - return new ConstructorDeclarationSyntax(modifiers, constructorKeyword, parameterList, block, semicolonToken, this.parsedInStrictMode()); + return new ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, this.parsedInStrictMode()); }; - ConstructorDeclarationSyntax.create = function (constructorKeyword, parameterList) { - return new ConstructorDeclarationSyntax(TypeScript.Syntax.emptyList, constructorKeyword, parameterList, null, null, false); + ConstructorDeclarationSyntax.create = function (constructorKeyword, callSignature) { + return new ConstructorDeclarationSyntax(TypeScript.Syntax.emptyList, constructorKeyword, callSignature, null, null, false); }; ConstructorDeclarationSyntax.create1 = function () { - return new ConstructorDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(62 /* ConstructorKeyword */), ParameterListSyntax.create1(), null, null, false); + return new ConstructorDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(62 /* ConstructorKeyword */), CallSignatureSyntax.create1(), null, null, false); }; ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { @@ -14104,7 +14206,7 @@ var TypeScript; }; ConstructorDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.constructorKeyword, this.parameterList, this.block, this.semicolonToken); + return this.update(modifiers, this.constructorKeyword, this.callSignature, this.block, this.semicolonToken); }; ConstructorDeclarationSyntax.prototype.withModifier = function (modifier) { @@ -14112,19 +14214,19 @@ var TypeScript; }; ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { - return this.update(this.modifiers, constructorKeyword, this.parameterList, this.block, this.semicolonToken); + return this.update(this.modifiers, constructorKeyword, this.callSignature, this.block, this.semicolonToken); }; - ConstructorDeclarationSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.constructorKeyword, parameterList, this.block, this.semicolonToken); + ConstructorDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.constructorKeyword, callSignature, this.block, this.semicolonToken); }; ConstructorDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.constructorKeyword, this.parameterList, block, this.semicolonToken); + return this.update(this.modifiers, this.constructorKeyword, this.callSignature, block, this.semicolonToken); }; ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.constructorKeyword, this.parameterList, this.block, semicolonToken); + return this.update(this.modifiers, this.constructorKeyword, this.callSignature, this.block, semicolonToken); }; ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { @@ -17614,7 +17716,7 @@ var TypeScript; }; SyntaxRewriter.prototype.visitConstructorDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.constructorKeyword), this.visitNode(node.parameterList), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + return node.update(this.visitList(node.modifiers), this.visitToken(node.constructorKeyword), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); }; SyntaxRewriter.prototype.visitMemberFunctionDeclaration = function (node) { @@ -18036,14 +18138,12 @@ var TypeScript; (function (TypeScript) { (function (Syntax) { var VariableWidthTokenWithNoTrivia = (function () { - function VariableWidthTokenWithNoTrivia(sourceText, fullStart, kind, textOrWidth) { - this._sourceText = sourceText; - this._fullStart = fullStart; + function VariableWidthTokenWithNoTrivia(fullText, kind) { + this._fullText = fullText; this.tokenKind = kind; - this._textOrWidth = textOrWidth; } VariableWidthTokenWithNoTrivia.prototype.clone = function () { - return new VariableWidthTokenWithNoTrivia(this._sourceText, this._fullStart, this.tokenKind, this._textOrWidth); + return new VariableWidthTokenWithNoTrivia(this._fullText, this.tokenKind); }; VariableWidthTokenWithNoTrivia.prototype.isNode = function () { @@ -18071,29 +18171,17 @@ var TypeScript; }; VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.width(); + return this.fullText().length; }; - VariableWidthTokenWithNoTrivia.prototype.start = function () { - return this._fullStart; - }; - VariableWidthTokenWithNoTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - VariableWidthTokenWithNoTrivia.prototype.width = function () { - return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); }; VariableWidthTokenWithNoTrivia.prototype.text = function () { - if (typeof this._textOrWidth === 'number') { - this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); - } - - return this._textOrWidth; + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); }; - VariableWidthTokenWithNoTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + return this._fullText; }; VariableWidthTokenWithNoTrivia.prototype.value = function () { @@ -18214,15 +18302,13 @@ var TypeScript; Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; var VariableWidthTokenWithLeadingTrivia = (function () { - function VariableWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, textOrWidth) { - this._sourceText = sourceText; - this._fullStart = fullStart; + function VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { + this._fullText = fullText; this.tokenKind = kind; this._leadingTriviaInfo = leadingTriviaInfo; - this._textOrWidth = textOrWidth; } VariableWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithLeadingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._textOrWidth); + return new VariableWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); }; VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { @@ -18250,29 +18336,17 @@ var TypeScript; }; VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width(); + return this.fullText().length; }; - VariableWidthTokenWithLeadingTrivia.prototype.start = function () { - return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - VariableWidthTokenWithLeadingTrivia.prototype.width = function () { - return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); }; VariableWidthTokenWithLeadingTrivia.prototype.text = function () { - if (typeof this._textOrWidth === 'number') { - this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); - } - - return this._textOrWidth; + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); }; - VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + return this._fullText; }; VariableWidthTokenWithLeadingTrivia.prototype.value = function () { @@ -18307,7 +18381,7 @@ var TypeScript; return getTriviaWidth(this._leadingTriviaInfo); }; VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); }; VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { @@ -18393,15 +18467,13 @@ var TypeScript; Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; var VariableWidthTokenWithTrailingTrivia = (function () { - function VariableWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, textOrWidth, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; + function VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { + this._fullText = fullText; this.tokenKind = kind; - this._textOrWidth = textOrWidth; this._trailingTriviaInfo = trailingTriviaInfo; } VariableWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._textOrWidth, this._trailingTriviaInfo); + return new VariableWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); }; VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { @@ -18429,29 +18501,17 @@ var TypeScript; }; VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.width() + getTriviaWidth(this._trailingTriviaInfo); + return this.fullText().length; }; - VariableWidthTokenWithTrailingTrivia.prototype.start = function () { - return this._fullStart; - }; - VariableWidthTokenWithTrailingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - VariableWidthTokenWithTrailingTrivia.prototype.width = function () { - return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); }; VariableWidthTokenWithTrailingTrivia.prototype.text = function () { - if (typeof this._textOrWidth === 'number') { - this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); - } - - return this._textOrWidth; + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); }; - VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + return this._fullText; }; VariableWidthTokenWithTrailingTrivia.prototype.value = function () { @@ -18505,7 +18565,7 @@ var TypeScript; return getTriviaWidth(this._trailingTriviaInfo); }; VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); }; VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { @@ -18572,16 +18632,14 @@ var TypeScript; Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { - function VariableWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, textOrWidth, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; + function VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo) { + this._fullText = fullText; this.tokenKind = kind; this._leadingTriviaInfo = leadingTriviaInfo; - this._textOrWidth = textOrWidth; this._trailingTriviaInfo = trailingTriviaInfo; } VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._textOrWidth, this._trailingTriviaInfo); + return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); }; VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { @@ -18609,29 +18667,17 @@ var TypeScript; }; VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width() + getTriviaWidth(this._trailingTriviaInfo); + return this.fullText().length; }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.start = function () { - return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { - return typeof this._textOrWidth === 'number' ? this._textOrWidth : this._textOrWidth.length; + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); }; VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { - if (typeof this._textOrWidth === 'number') { - this._textOrWidth = this._sourceText.substr(this.start(), this._textOrWidth, this.tokenKind === 11 /* IdentifierName */); - } - - return this._textOrWidth; + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + return this._fullText; }; VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { @@ -18666,7 +18712,7 @@ var TypeScript; return getTriviaWidth(this._leadingTriviaInfo); }; VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); }; VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { @@ -18685,7 +18731,7 @@ var TypeScript; return getTriviaWidth(this._trailingTriviaInfo); }; VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); }; VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { @@ -18784,11 +18830,12 @@ var TypeScript; }; FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.width(); + return this.fullText().length; }; FixedWidthTokenWithNoTrivia.prototype.width = function () { return this.text().length; }; + FixedWidthTokenWithNoTrivia.prototype.text = function () { return TypeScript.SyntaxFacts.getText(this.tokenKind); }; @@ -18904,14 +18951,13 @@ var TypeScript; Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; var FixedWidthTokenWithLeadingTrivia = (function () { - function FixedWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; + function FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { + this._fullText = fullText; this.tokenKind = kind; this._leadingTriviaInfo = leadingTriviaInfo; } FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithLeadingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo); + return new FixedWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); }; FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { @@ -18939,23 +18985,17 @@ var TypeScript; }; FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width(); + return this.fullText().length; }; - FixedWidthTokenWithLeadingTrivia.prototype.start = function () { - return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - FixedWidthTokenWithLeadingTrivia.prototype.width = function () { return this.text().length; }; + FixedWidthTokenWithLeadingTrivia.prototype.text = function () { return TypeScript.SyntaxFacts.getText(this.tokenKind); }; FixedWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + return this._fullText; }; FixedWidthTokenWithLeadingTrivia.prototype.value = function () { @@ -18980,7 +19020,7 @@ var TypeScript; return getTriviaWidth(this._leadingTriviaInfo); }; FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); }; FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { @@ -19066,14 +19106,13 @@ var TypeScript; Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; var FixedWidthTokenWithTrailingTrivia = (function () { - function FixedWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; + function FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { + this._fullText = fullText; this.tokenKind = kind; this._trailingTriviaInfo = trailingTriviaInfo; } FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._trailingTriviaInfo); + return new FixedWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); }; FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { @@ -19101,23 +19140,17 @@ var TypeScript; }; FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.width() + getTriviaWidth(this._trailingTriviaInfo); + return this.fullText().length; }; - FixedWidthTokenWithTrailingTrivia.prototype.start = function () { - return this._fullStart; - }; - FixedWidthTokenWithTrailingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - FixedWidthTokenWithTrailingTrivia.prototype.width = function () { return this.text().length; }; + FixedWidthTokenWithTrailingTrivia.prototype.text = function () { return TypeScript.SyntaxFacts.getText(this.tokenKind); }; FixedWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + return this._fullText; }; FixedWidthTokenWithTrailingTrivia.prototype.value = function () { @@ -19161,7 +19194,7 @@ var TypeScript; return getTriviaWidth(this._trailingTriviaInfo); }; FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); }; FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { @@ -19228,15 +19261,14 @@ var TypeScript; Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { - function FixedWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; + function FixedWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo) { + this._fullText = fullText; this.tokenKind = kind; this._leadingTriviaInfo = leadingTriviaInfo; this._trailingTriviaInfo = trailingTriviaInfo; } FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithLeadingAndTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); + return new FixedWidthTokenWithLeadingAndTrailingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); }; FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { @@ -19264,23 +19296,17 @@ var TypeScript; }; FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width() + getTriviaWidth(this._trailingTriviaInfo); + return this.fullText().length; }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.start = function () { - return this._fullStart + getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.end = function () { - return this.start() + this.width(); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { return this.text().length; }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { return TypeScript.SyntaxFacts.getText(this.tokenKind); }; FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); + return this._fullText; }; FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { @@ -19305,7 +19331,7 @@ var TypeScript; return getTriviaWidth(this._leadingTriviaInfo); }; FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); }; FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { @@ -19324,7 +19350,7 @@ var TypeScript; return getTriviaWidth(this._trailingTriviaInfo); }; FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); }; FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { @@ -19396,36 +19422,6 @@ var TypeScript; token.trailingTrivia().collectTextElements(elements); } - function fixedWidthToken(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo) { - if (leadingTriviaInfo === 0) { - if (trailingTriviaInfo === 0) { - return new FixedWidthTokenWithNoTrivia(kind); - } else { - return new FixedWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new FixedWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo); - } else { - return new FixedWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo); - } - } - Syntax.fixedWidthToken = fixedWidthToken; - - function variableWidthToken(sourceText, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo) { - if (leadingTriviaInfo === 0) { - if (trailingTriviaInfo === 0) { - return new VariableWidthTokenWithNoTrivia(sourceText, fullStart, kind, width); - } else { - return new VariableWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, width, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new VariableWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, width); - } else { - return new VariableWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo); - } - } - Syntax.variableWidthToken = variableWidthToken; - function getTriviaWidth(value) { return value >>> 2 /* TriviaFullWidthShift */; } @@ -19615,7 +19611,7 @@ var TypeScript; case 13 /* carriageReturn */: var nextIndex = i + 1; - if (nextIndex < text.length && text.charCodeAt(nextIndex) == 10 /* lineFeed */) { + if (nextIndex < text.length && text.charCodeAt(nextIndex) === 10 /* lineFeed */) { i++; } continue; @@ -21363,7 +21359,7 @@ var TypeScript; SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { this.visitList(node.modifiers); this.visitToken(node.constructorKeyword); - this.visitNode(node.parameterList); + this.visitNode(node.callSignature); this.visitOptionalNode(node.block); this.visitOptionalToken(node.semicolonToken); }; @@ -21831,7 +21827,7 @@ var TypeScript; ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; - ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeArgumentList_Types] = "LastListParsingState"; + ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeParameterList_TypeParameters] = "LastListParsingState"; })(ListParsingState || (ListParsingState = {})); var SyntaxCursor = (function () { @@ -23200,13 +23196,13 @@ var TypeScript; ParserImpl.prototype.isConstructorDeclaration = function () { var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 62 /* ConstructorKeyword */ && this.peekToken(index + 1).tokenKind === 72 /* OpenParenToken */; + return this.peekToken(index).tokenKind === 62 /* ConstructorKeyword */; }; ParserImpl.prototype.parseConstructorDeclaration = function () { var modifiers = this.parseModifiers(); var constructorKeyword = this.eatKeyword(62 /* ConstructorKeyword */); - var parameterList = this.parseParameterList(); + var callSignature = this.parseCallSignature(false); var semicolonToken = null; var block = null; @@ -23217,7 +23213,7 @@ var TypeScript; semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); } - return this.factory.constructorDeclaration(modifiers, constructorKeyword, parameterList, block, semicolonToken); + return this.factory.constructorDeclaration(modifiers, constructorKeyword, callSignature, block, semicolonToken); }; ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { @@ -25091,10 +25087,6 @@ var TypeScript; var currentToken = this.currentToken(); var currentTokenKind = currentToken.tokenKind; - if (currentTokenKind === 39 /* TypeOfKeyword */) { - return this.parseTypeQuery(); - } - var type = this.parseNonArrayType(currentToken); while (this.currentToken().tokenKind === 74 /* OpenBracketToken */) { @@ -25137,6 +25129,9 @@ var TypeScript; case 31 /* NewKeyword */: return this.parseConstructorType(); + + case 39 /* TypeOfKeyword */: + return this.parseTypeQuery(); } return this.parseNameOrGenericType(); @@ -25262,7 +25257,7 @@ var TypeScript; ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { this.reportUnexpectedTokenDiagnostic(currentListType); - for (var state = 262144 /* LastListParsingState */; state >= 1 /* FirstListParsingState */; state >>= 1) { + for (var state = 524288 /* LastListParsingState */; state >= 1 /* FirstListParsingState */; state >>= 1) { if ((this.listParsingState & state) !== 0) { if (this.isExpectedListTerminator(state) || this.isExpectedListItem(state, true)) { return true; @@ -26098,14 +26093,11 @@ var TypeScript; return true; } - if (this.inAmbientDeclaration) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Parameter_property_declarations_cannot_be_used_in_an_ambient_context); - return true; - } else if (this.currentConstructor && !this.currentConstructor.block && this.currentConstructor.parameterList === parameterList) { + if (!this.inAmbientDeclaration && this.currentConstructor && !this.currentConstructor.block && this.currentConstructor.callSignature.parameterList === parameterList) { this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Parameter_property_declarations_cannot_be_used_in_a_constructor_overload); return true; - } else if (this.currentConstructor === null || this.currentConstructor.parameterList !== parameterList) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Parameter_property_declarations_can_only_be_used_in_constructors); + } else if (this.inAmbientDeclaration || this.currentConstructor === null || this.currentConstructor.callSignature.parameterList !== parameterList) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Parameter_property_declarations_can_only_be_used_in_a_non_ambient_constructor_declaration); return true; } } @@ -26337,9 +26329,22 @@ var TypeScript; inFunctionOverloadChain = functionDeclaration.block === null; functionOverloadChainName = functionDeclaration.identifier.valueText(); - if (lastElement && inFunctionOverloadChain) { - this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; + if (inFunctionOverloadChain) { + if (lastElement) { + this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } else { + var nextElement = moduleElements.childAt(i + 1); + if (nextElement.kind() === 129 /* FunctionDeclaration */) { + var nextFunction = nextElement; + + if (nextFunction.identifier.valueText() !== functionOverloadChainName && nextFunction.block === null) { + var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); + this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + } + } } } else { inFunctionOverloadChain = false; @@ -26382,9 +26387,10 @@ var TypeScript; this.pushDiagnostic1(propertyNameFullStart, memberFunctionDeclaration.propertyName, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); return true; } + isStaticOverload = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); if (isStaticOverload !== isInStaticOverloadChain) { - propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); + var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); var diagnostic = isInStaticOverloadChain ? TypeScript.DiagnosticCode.Function_overload_must_be_static : TypeScript.DiagnosticCode.Function_overload_must_not_be_static; this.pushDiagnostic1(propertyNameFullStart, memberFunctionDeclaration.propertyName, diagnostic, null); return true; @@ -26403,9 +26409,22 @@ var TypeScript; functionOverloadChainName = memberFunctionDeclaration.propertyName.valueText(); isInStaticOverloadChain = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); - if (lastElement && inFunctionOverloadChain) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; + if (inFunctionOverloadChain) { + if (lastElement) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } else { + var nextElement = node.classElements.childAt(i + 1); + if (nextElement.kind() === 135 /* MemberFunctionDeclaration */) { + var nextMemberFunction = nextElement; + + if (nextMemberFunction.propertyName.valueText() !== functionOverloadChainName && nextMemberFunction.block === null) { + var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); + this.pushDiagnostic1(propertyNameFullStart, memberFunctionDeclaration.propertyName, TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + } + } } } else if (classElement.kind() === 137 /* ConstructorDeclaration */) { var constructorDeclaration = classElement; @@ -26696,23 +26715,21 @@ var TypeScript; GrammarCheckerWalker.prototype.checkEnumElements = function (node) { var enumElementFullStart = this.childFullStart(node, node.enumElements); - var seenComputedValue = false; + var previousValueWasComputed = false; for (var i = 0, n = node.enumElements.childCount(); i < n; i++) { var child = node.enumElements.childAt(i); if (i % 2 === 0) { var enumElement = child; - if (!enumElement.equalsValueClause && seenComputedValue) { + if (!enumElement.equalsValueClause && previousValueWasComputed) { this.pushDiagnostic1(enumElementFullStart, enumElement, TypeScript.DiagnosticCode.Enum_member_must_have_initializer, null); return true; } if (enumElement.equalsValueClause) { var value = enumElement.equalsValueClause.value; - if (!TypeScript.Syntax.isIntegerLiteral(value)) { - seenComputedValue = true; - } + previousValueWasComputed = !TypeScript.Syntax.isIntegerLiteral(value); } } @@ -26999,7 +27016,7 @@ var TypeScript; }; GrammarCheckerWalker.prototype.visitForInStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { + if (this.checkForStatementInAmbientContxt(node) || this.checkForInStatementVariableDeclaration(node)) { this.skip(node); return; } @@ -27007,6 +27024,17 @@ var TypeScript; _super.prototype.visitForInStatement.call(this, node); }; + GrammarCheckerWalker.prototype.checkForInStatementVariableDeclaration = function (node) { + if (node.variableDeclaration && node.variableDeclaration.variableDeclarators.nonSeparatorCount() > 1) { + var variableDeclarationFullStart = this.childFullStart(node, node.variableDeclaration); + + this.pushDiagnostic1(variableDeclarationFullStart, node.variableDeclaration, TypeScript.DiagnosticCode.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement); + return true; + } + + return false; + }; + GrammarCheckerWalker.prototype.visitForStatement = function (node) { if (this.checkForStatementInAmbientContxt(node)) { this.skip(node); @@ -27183,7 +27211,7 @@ var TypeScript; }; GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers) || this.checkConstructorModifiers(node.modifiers)) { + if (this.checkClassElementModifiers(node.modifiers) || this.checkConstructorModifiers(node.modifiers) || this.checkConstructorTypeParameterList(node) || this.checkConstructorTypeAnnotation(node)) { this.skip(node); return; } @@ -27210,6 +27238,32 @@ var TypeScript; return false; }; + GrammarCheckerWalker.prototype.checkConstructorTypeParameterList = function (node) { + var currentElementFullStart = this.position(); + + if (node.callSignature.typeParameterList) { + var callSignatureFullStart = this.childFullStart(node, node.callSignature); + var typeParameterListFullStart = callSignatureFullStart + TypeScript.Syntax.childOffset(node.callSignature, node.callSignature.typeAnnotation); + this.pushDiagnostic1(callSignatureFullStart, node.callSignature.typeParameterList, TypeScript.DiagnosticCode.Type_parameters_cannot_appear_on_a_constructor_declaration); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkConstructorTypeAnnotation = function (node) { + var currentElementFullStart = this.position(); + + if (node.callSignature.typeAnnotation) { + var callSignatureFullStart = this.childFullStart(node, node.callSignature); + var typeAnnotationFullStart = callSignatureFullStart + TypeScript.Syntax.childOffset(node.callSignature, node.callSignature.typeAnnotation); + this.pushDiagnostic1(typeAnnotationFullStart, node.callSignature.typeAnnotation, TypeScript.DiagnosticCode.Type_annotation_cannot_appear_on_a_constructor_declaration); + return true; + } + + return false; + }; + GrammarCheckerWalker.prototype.visitSourceUnit = function (node) { if (this.checkFunctionOverloads(node, node.moduleElements) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { this.skip(node); @@ -27343,7 +27397,9 @@ var TypeScript; var start = (new Date()).getTime(); var result = func(); var end = (new Date()).getTime(); - logger.log(funcDescription + " completed in " + (end - start) + " msec"); + if (logger.information()) { + logger.log(funcDescription + " completed in " + (end - start) + " msec"); + } return result; } TypeScript.timeFunction = timeFunction; @@ -27368,8 +27424,8 @@ var TypeScript; this._lineMap = null; this._declASTMap = []; this._astDeclMap = []; - this._isExternalModule = undefined; this._amdDependencies = undefined; + this._externalModuleIndicatorSpan = undefined; } Document.prototype.invalidate = function () { this._declASTMap.length = 0; @@ -27394,39 +27450,22 @@ var TypeScript; this._lineMap = syntaxTree.lineMap(); var sourceUnit = syntaxTree.sourceUnit(); - var leadingComments = this.getLeadingComments(sourceUnit); + var leadingTrivia = sourceUnit.leadingTrivia(); - this._isExternalModule = this.hasImplicitImport(leadingComments) || this.hasTopLevelImportOrExport(sourceUnit); + this._externalModuleIndicatorSpan = this.getImplicitImportSpan(leadingTrivia) || this.getTopLevelImportOrExportSpan(sourceUnit); var amdDependencies = []; - for (var i = 0, n = leadingComments.length; i < n; i++) { - var trivia = leadingComments[i]; - var amdDependency = this.getAmdDependency(trivia.fullText()); - if (amdDependency) { - amdDependencies.push(amdDependency); - } - } - - this._amdDependencies = amdDependencies; - }; - - Document.prototype.getLeadingComments = function (node) { - var firstToken = node.firstToken(); - var result = []; - - if (firstToken.hasLeadingComment()) { - var leadingTrivia = firstToken.leadingTrivia(); - - for (var i = 0, n = leadingTrivia.count(); i < n; i++) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - - if (trivia.isComment()) { - result.push(trivia); + for (var i = 0, n = leadingTrivia.count(); i < n; i++) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + if (trivia.isComment()) { + var amdDependency = this.getAmdDependency(trivia.fullText()); + if (amdDependency) { + amdDependencies.push(amdDependency); } } } - return result; + this._amdDependencies = amdDependencies; }; Document.prototype.getAmdDependency = function (comment) { @@ -27435,49 +27474,60 @@ var TypeScript; return match ? match[2] : null; }; - Document.prototype.hasImplicitImport = function (sourceUnitLeadingComments) { - for (var i = 0, n = sourceUnitLeadingComments.length; i < n; i++) { - var trivia = sourceUnitLeadingComments[i]; + Document.prototype.getImplicitImportSpan = function (sourceUnitLeadingTrivia) { + var position = 0; - if (this.getImplicitImport(trivia.fullText())) { - return true; + for (var i = 0, n = sourceUnitLeadingTrivia.count(); i < n; i++) { + var trivia = sourceUnitLeadingTrivia.syntaxTriviaAt(i); + + if (trivia.isComment()) { + var span = this.getImplicitImportSpanWorker(trivia, position); + if (span) { + return span; + } } + + position += trivia.fullWidth(); } - return false; + return null; }; - Document.prototype.getImplicitImport = function (comment) { + Document.prototype.getImplicitImportSpanWorker = function (trivia, position) { var implicitImportRegEx = /^(\/\/\/\s*/gim; - var match = implicitImportRegEx.exec(comment); + var match = implicitImportRegEx.exec(trivia.fullText()); if (match) { - return true; + return new TypeScript.TextSpan(position, trivia.fullWidth()); } - return false; + return null; }; - Document.prototype.hasTopLevelImportOrExport = function (node) { + Document.prototype.getTopLevelImportOrExportSpan = function (node) { var firstToken; + var position = 0; for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { var moduleElement = node.moduleElements.childAt(i); firstToken = moduleElement.firstToken(); if (firstToken !== null && firstToken.tokenKind === 47 /* ExportKeyword */) { - return true; + return new TypeScript.TextSpan(position + firstToken.leadingTriviaWidth(), firstToken.width()); } if (moduleElement.kind() === 133 /* ImportDeclaration */) { var importDecl = moduleElement; if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { - return true; + return new TypeScript.TextSpan(position + importDecl.leadingTriviaWidth(), importDecl.width()); } } + + position += moduleElement.fullWidth(); } - return false; + return null; + ; }; Document.prototype.sourceUnit = function () { @@ -27514,12 +27564,16 @@ var TypeScript; }; Document.prototype.isExternalModule = function () { - if (this._isExternalModule === undefined) { + return this.externalModuleIndicatorSpan() !== null; + }; + + Document.prototype.externalModuleIndicatorSpan = function () { + if (this._externalModuleIndicatorSpan === undefined) { this.syntaxTree(); - TypeScript.Debug.assert(this._isExternalModule !== undefined); + TypeScript.Debug.assert(this._externalModuleIndicatorSpan !== undefined); } - return this._isExternalModule; + return this._externalModuleIndicatorSpan; }; Document.prototype.amdDependencies = function () { @@ -27553,7 +27607,7 @@ var TypeScript; if (!this._bloomFilter) { var identifiers = TypeScript.createIntrinsicsObject(); var pre = function (cur) { - if (TypeScript.isValidAstNode(cur)) { + if (TypeScript.ASTHelpers.isValidAstNode(cur)) { if (cur.kind() === 11 /* IdentifierName */) { var nodeText = cur.valueText(); @@ -27859,246 +27913,261 @@ var TypeScript; })(StringHashTable); TypeScript.IdentiferNameHashTable = IdentiferNameHashTable; })(TypeScript || (TypeScript = {})); + var TypeScript; (function (TypeScript) { - function scriptIsElided(sourceUnit) { - return TypeScript.isDTSFile(sourceUnit.fileName()) || moduleMembersAreElided(sourceUnit.moduleElements); - } - TypeScript.scriptIsElided = scriptIsElided; + (function (ASTHelpers) { + function scriptIsElided(sourceUnit) { + return TypeScript.isDTSFile(sourceUnit.fileName()) || moduleMembersAreElided(sourceUnit.moduleElements); + } + ASTHelpers.scriptIsElided = scriptIsElided; - function moduleIsElided(declaration) { - return TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) || moduleMembersAreElided(declaration.moduleElements); - } - TypeScript.moduleIsElided = moduleIsElided; + function moduleIsElided(declaration) { + return TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) || moduleMembersAreElided(declaration.moduleElements); + } + ASTHelpers.moduleIsElided = moduleIsElided; - function moduleMembersAreElided(members) { - for (var i = 0, n = members.childCount(); i < n; i++) { - var member = members.childAt(i); + function moduleMembersAreElided(members) { + for (var i = 0, n = members.childCount(); i < n; i++) { + var member = members.childAt(i); - if (member.kind() === 130 /* ModuleDeclaration */) { - if (!moduleIsElided(member)) { + if (member.kind() === 130 /* ModuleDeclaration */) { + if (!moduleIsElided(member)) { + return false; + } + } else if (member.kind() !== 128 /* InterfaceDeclaration */) { return false; } - } else if (member.kind() !== 128 /* InterfaceDeclaration */) { - return false; } - } - return true; - } - - function enumIsElided(declaration) { - if (TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */)) { return true; } - return false; - } - TypeScript.enumIsElided = enumIsElided; - - function importDeclarationIsElided(importDeclAST, semanticInfoChain, compilationSettings) { - if (typeof compilationSettings === "undefined") { compilationSettings = null; } - var isExternalModuleReference = importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */; - var importDecl = semanticInfoChain.getDeclForAST(importDeclAST); - var isExported = TypeScript.hasFlag(importDecl.flags, 1 /* Exported */); - var isAmdCodeGen = compilationSettings && compilationSettings.moduleGenTarget() == 2 /* Asynchronous */; - - if (!isExternalModuleReference || isExported || !isAmdCodeGen) { - var importSymbol = importDecl.getSymbol(); - if (importDeclAST.moduleReference.kind() !== 245 /* ExternalModuleReference */) { - if (importSymbol.getExportAssignedValueSymbol()) { - return true; - } - var containerSymbol = importSymbol.getExportAssignedContainerSymbol(); - if (containerSymbol && containerSymbol.getInstanceSymbol()) { - return true; - } + function enumIsElided(declaration) { + if (TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */)) { + return true; } - return importSymbol.isUsedAsValue(); + return false; } + ASTHelpers.enumIsElided = enumIsElided; - return false; - } - TypeScript.importDeclarationIsElided = importDeclarationIsElided; + function isValidAstNode(ast) { + if (!ast) + return false; - function isValidAstNode(ast) { - if (!ast) - return false; + if (ast.start() === -1 || ast.end() === -1) + return false; - if (ast.start() === -1 || ast.end() === -1) - return false; + return true; + } + ASTHelpers.isValidAstNode = isValidAstNode; - return true; - } - TypeScript.isValidAstNode = isValidAstNode; + function getAstAtPosition(script, pos, useTrailingTriviaAsLimChar, forceInclusive) { + if (typeof useTrailingTriviaAsLimChar === "undefined") { useTrailingTriviaAsLimChar = true; } + if (typeof forceInclusive === "undefined") { forceInclusive = false; } + var top = null; - function getAstAtPosition(script, pos, useTrailingTriviaAsLimChar, forceInclusive) { - if (typeof useTrailingTriviaAsLimChar === "undefined") { useTrailingTriviaAsLimChar = true; } - if (typeof forceInclusive === "undefined") { forceInclusive = false; } - var top = null; + var pre = function (cur, walker) { + if (isValidAstNode(cur)) { + var isInvalid1 = cur.kind() === 149 /* ExpressionStatement */ && cur.width() === 0; - var pre = function (cur, walker) { - if (isValidAstNode(cur)) { - var isInvalid1 = cur.kind() === 149 /* ExpressionStatement */ && cur.width() === 0; + if (isInvalid1) { + walker.options.goChildren = false; + } else { + var inclusive = forceInclusive || cur.kind() === 11 /* IdentifierName */ || cur.kind() === 212 /* MemberAccessExpression */ || cur.kind() === 121 /* QualifiedName */ || cur.kind() === 224 /* VariableDeclaration */ || cur.kind() === 225 /* VariableDeclarator */ || cur.kind() === 213 /* InvocationExpression */ || pos === script.end() + script.trailingTriviaWidth(); - if (isInvalid1) { - walker.options.goChildren = false; - } else { - var inclusive = forceInclusive || cur.kind() === 11 /* IdentifierName */ || cur.kind() === 212 /* MemberAccessExpression */ || cur.kind() === 121 /* QualifiedName */ || cur.kind() === 224 /* VariableDeclaration */ || cur.kind() === 225 /* VariableDeclarator */ || cur.kind() === 213 /* InvocationExpression */ || pos === script.end() + script.trailingTriviaWidth(); - - var minChar = cur.start(); - var limChar = cur.end() + (useTrailingTriviaAsLimChar ? cur.trailingTriviaWidth() : 0) + (inclusive ? 1 : 0); - if (pos >= minChar && pos < limChar) { - if ((cur.kind() !== 1 /* List */ && cur.kind() !== 2 /* SeparatedList */) || cur.end() > cur.start()) { - if (top === null) { - top = cur; - } else if (cur.start() >= top.start() && (cur.end() + (useTrailingTriviaAsLimChar ? cur.trailingTriviaWidth() : 0)) <= (top.end() + (useTrailingTriviaAsLimChar ? top.trailingTriviaWidth() : 0))) { - if (top.width() !== 0 || cur.width() !== 0) { + var minChar = cur.start(); + var limChar = cur.end() + (useTrailingTriviaAsLimChar ? cur.trailingTriviaWidth() : 0) + (inclusive ? 1 : 0); + if (pos >= minChar && pos < limChar) { + if ((cur.kind() !== 1 /* List */ && cur.kind() !== 2 /* SeparatedList */) || cur.end() > cur.start()) { + if (top === null) { top = cur; + } else if (cur.start() >= top.start() && (cur.end() + (useTrailingTriviaAsLimChar ? cur.trailingTriviaWidth() : 0)) <= (top.end() + (useTrailingTriviaAsLimChar ? top.trailingTriviaWidth() : 0))) { + if (top.width() !== 0 || cur.width() !== 0) { + top = cur; + } } } } - } - walker.options.goChildren = (minChar <= pos && pos <= limChar); + walker.options.goChildren = (minChar <= pos && pos <= limChar); + } + } + }; + + TypeScript.getAstWalkerFactory().walk(script, pre); + return top; + } + ASTHelpers.getAstAtPosition = getAstAtPosition; + + function getExtendsHeritageClause(clauses) { + if (!clauses) { + return null; + } + + return clauses.firstOrDefault(function (c) { + return c.typeNames.nonSeparatorCount() > 0 && c.kind() === 230 /* ExtendsHeritageClause */; + }); + } + ASTHelpers.getExtendsHeritageClause = getExtendsHeritageClause; + + function getImplementsHeritageClause(clauses) { + if (!clauses) { + return null; + } + + return clauses.firstOrDefault(function (c) { + return c.typeNames.nonSeparatorCount() > 0 && c.kind() === 231 /* ImplementsHeritageClause */; + }); + } + ASTHelpers.getImplementsHeritageClause = getImplementsHeritageClause; + + function isCallExpression(ast) { + return (ast && ast.kind() === 213 /* InvocationExpression */) || (ast && ast.kind() === 216 /* ObjectCreationExpression */); + } + ASTHelpers.isCallExpression = isCallExpression; + + function isCallExpressionTarget(ast) { + if (!ast) { + return false; + } + + var current = ast; + + while (current && current.parent) { + if (current.parent.kind() === 212 /* MemberAccessExpression */ && current.parent.name === current) { + current = current.parent; + continue; + } + + break; + } + + if (current && current.parent) { + if (current.parent.kind() === 213 /* InvocationExpression */ || current.parent.kind() === 216 /* ObjectCreationExpression */) { + return current === current.parent.expression; } } - }; - TypeScript.getAstWalkerFactory().walk(script, pre); - return top; - } - TypeScript.getAstAtPosition = getAstAtPosition; - - function getExtendsHeritageClause(clauses) { - if (!clauses) { - return null; + return false; } + ASTHelpers.isCallExpressionTarget = isCallExpressionTarget; - return clauses.firstOrDefault(function (c) { - return c.typeNames.nonSeparatorCount() > 0 && c.kind() === 230 /* ExtendsHeritageClause */; - }); - } - TypeScript.getExtendsHeritageClause = getExtendsHeritageClause; + function isNameOfSomeDeclaration(ast) { + if (ast === null || ast.parent === null) { + return false; + } + if (ast.kind() !== 11 /* IdentifierName */) { + return false; + } - function getImplementsHeritageClause(clauses) { - if (!clauses) { - return null; - } + switch (ast.parent.kind()) { + case 131 /* ClassDeclaration */: + return ast.parent.identifier === ast; + case 128 /* InterfaceDeclaration */: + return ast.parent.identifier === ast; + case 132 /* EnumDeclaration */: + return ast.parent.identifier === ast; + case 130 /* ModuleDeclaration */: + return ast.parent.name === ast || ast.parent.stringLiteral === ast; + case 225 /* VariableDeclarator */: + return ast.parent.propertyName === ast; + case 129 /* FunctionDeclaration */: + return ast.parent.identifier === ast; + case 135 /* MemberFunctionDeclaration */: + return ast.parent.propertyName === ast; + case 242 /* Parameter */: + return ast.parent.identifier === ast; + case 238 /* TypeParameter */: + return ast.parent.identifier === ast; + case 240 /* SimplePropertyAssignment */: + return ast.parent.propertyName === ast; + case 241 /* FunctionPropertyAssignment */: + return ast.parent.propertyName === ast; + case 243 /* EnumElement */: + return ast.parent.propertyName === ast; + case 133 /* ImportDeclaration */: + return ast.parent.identifier === ast; + } - return clauses.firstOrDefault(function (c) { - return c.typeNames.nonSeparatorCount() > 0 && c.kind() === 231 /* ImplementsHeritageClause */; - }); - } - TypeScript.getImplementsHeritageClause = getImplementsHeritageClause; - - function isCallExpression(ast) { - return (ast && ast.kind() === 213 /* InvocationExpression */) || (ast && ast.kind() === 216 /* ObjectCreationExpression */); - } - TypeScript.isCallExpression = isCallExpression; - - function isCallExpressionTarget(ast) { - if (!ast) { return false; } - var current = ast; + function isDeclarationASTOrDeclarationNameAST(ast) { + return isNameOfSomeDeclaration(ast) || isDeclarationAST(ast); + } + ASTHelpers.isDeclarationASTOrDeclarationNameAST = isDeclarationASTOrDeclarationNameAST; + + function getEnclosingParameterForInitializer(ast) { + var current = ast; + while (current) { + switch (current.kind()) { + case 232 /* EqualsValueClause */: + if (current.parent && current.parent.kind() === 242 /* Parameter */) { + return current.parent; + } + break; + case 131 /* ClassDeclaration */: + case 128 /* InterfaceDeclaration */: + case 130 /* ModuleDeclaration */: + return null; + } - while (current && current.parent) { - if (current.parent.kind() === 212 /* MemberAccessExpression */ && current.parent.name === current) { current = current.parent; - continue; + } + return null; + } + ASTHelpers.getEnclosingParameterForInitializer = getEnclosingParameterForInitializer; + + function getEnclosingMemberVariableDeclaration(ast) { + var current = ast; + + while (current) { + switch (current.kind()) { + case 136 /* MemberVariableDeclaration */: + return current; + case 131 /* ClassDeclaration */: + case 128 /* InterfaceDeclaration */: + case 130 /* ModuleDeclaration */: + return null; + } + current = current.parent; } - break; + return null; } + ASTHelpers.getEnclosingMemberVariableDeclaration = getEnclosingMemberVariableDeclaration; - if (current && current.parent) { - if (current.parent.kind() === 213 /* InvocationExpression */ || current.parent.kind() === 216 /* ObjectCreationExpression */) { - return current === current.parent.expression; + function isNameOfFunction(ast) { + return ast && ast.parent && ast.kind() === 11 /* IdentifierName */ && ast.parent.kind() === 129 /* FunctionDeclaration */ && ast.parent.identifier === ast; + } + ASTHelpers.isNameOfFunction = isNameOfFunction; + + function isNameOfMemberFunction(ast) { + return ast && ast.parent && ast.kind() === 11 /* IdentifierName */ && ast.parent.kind() === 135 /* MemberFunctionDeclaration */ && ast.parent.propertyName === ast; + } + ASTHelpers.isNameOfMemberFunction = isNameOfMemberFunction; + + function isNameOfMemberAccessExpression(ast) { + if (ast && ast.parent && ast.parent.kind() === 212 /* MemberAccessExpression */ && ast.parent.name === ast) { + return true; } - } - return false; - } - TypeScript.isCallExpressionTarget = isCallExpressionTarget; - - function isNameOfSomeDeclaration(ast) { - if (ast === null || ast.parent === null) { return false; } - if (ast.kind() !== 11 /* IdentifierName */) { + ASTHelpers.isNameOfMemberAccessExpression = isNameOfMemberAccessExpression; + + function isRightSideOfQualifiedName(ast) { + if (ast && ast.parent && ast.parent.kind() === 121 /* QualifiedName */ && ast.parent.right === ast) { + return true; + } + return false; } + ASTHelpers.isRightSideOfQualifiedName = isRightSideOfQualifiedName; - switch (ast.parent.kind()) { - case 131 /* ClassDeclaration */: - return ast.parent.identifier === ast; - case 128 /* InterfaceDeclaration */: - return ast.parent.identifier === ast; - case 132 /* EnumDeclaration */: - return ast.parent.identifier === ast; - case 130 /* ModuleDeclaration */: - return ast.parent.name === ast || ast.parent.stringLiteral === ast; - case 225 /* VariableDeclarator */: - return ast.parent.propertyName === ast; - case 129 /* FunctionDeclaration */: - return ast.parent.identifier === ast; - case 135 /* MemberFunctionDeclaration */: - return ast.parent.propertyName === ast; - case 242 /* Parameter */: - return ast.parent.identifier === ast; - case 238 /* TypeParameter */: - return ast.parent.identifier === ast; - case 240 /* SimplePropertyAssignment */: - return ast.parent.propertyName === ast; - case 241 /* FunctionPropertyAssignment */: - return ast.parent.propertyName === ast; - case 243 /* EnumElement */: - return ast.parent.propertyName === ast; - case 133 /* ImportDeclaration */: - return ast.parent.identifier === ast; - } - - return false; - } - - function isDeclarationASTOrDeclarationNameAST(ast) { - return isNameOfSomeDeclaration(ast) || isDeclarationAST(ast); - } - TypeScript.isDeclarationASTOrDeclarationNameAST = isDeclarationASTOrDeclarationNameAST; - - function isNameOfFunction(ast) { - return ast && ast.parent && ast.kind() === 11 /* IdentifierName */ && ast.parent.kind() === 129 /* FunctionDeclaration */ && ast.parent.identifier === ast; - } - TypeScript.isNameOfFunction = isNameOfFunction; - - function isNameOfMemberFunction(ast) { - return ast && ast.parent && ast.kind() === 11 /* IdentifierName */ && ast.parent.kind() === 135 /* MemberFunctionDeclaration */ && ast.parent.propertyName === ast; - } - TypeScript.isNameOfMemberFunction = isNameOfMemberFunction; - - function isNameOfMemberAccessExpression(ast) { - if (ast && ast.parent && ast.parent.kind() === 212 /* MemberAccessExpression */ && ast.parent.name === ast) { - return true; - } - - return false; - } - TypeScript.isNameOfMemberAccessExpression = isNameOfMemberAccessExpression; - - function isRightSideOfQualifiedName(ast) { - if (ast && ast.parent && ast.parent.kind() === 121 /* QualifiedName */ && ast.parent.right === ast) { - return true; - } - - return false; - } - TypeScript.isRightSideOfQualifiedName = isRightSideOfQualifiedName; - - (function (Parameters) { - function fromIdentifier(id) { + function parametersFromIdentifier(id) { return { length: 1, lastParameterIsRest: function () { @@ -28122,9 +28191,9 @@ var TypeScript; } }; } - Parameters.fromIdentifier = fromIdentifier; + ASTHelpers.parametersFromIdentifier = parametersFromIdentifier; - function fromParameter(parameter) { + function parametersFromParameter(parameter) { return { length: 1, lastParameterIsRest: function () { @@ -28138,7 +28207,7 @@ var TypeScript; return parameter.identifier; }, typeAt: function (index) { - return TypeScript.getType(parameter); + return getType(parameter); }, initializerAt: function (index) { return parameter.equalsValueClause; @@ -28148,13 +28217,13 @@ var TypeScript; } }; } - Parameters.fromParameter = fromParameter; + ASTHelpers.parametersFromParameter = parametersFromParameter; function parameterIsOptional(parameter) { return parameter.questionToken !== null || parameter.equalsValueClause !== null; } - function fromParameterList(list) { + function parametersFromParameterList(list) { return { length: list.parameters.nonSeparatorCount(), lastParameterIsRest: function () { @@ -28168,7 +28237,7 @@ var TypeScript; return list.parameters.nonSeparatorAt(index).identifier; }, typeAt: function (index) { - return TypeScript.getType(list.parameters.nonSeparatorAt(index)); + return getType(list.parameters.nonSeparatorAt(index)); }, initializerAt: function (index) { return list.parameters.nonSeparatorAt(index).equalsValueClause; @@ -28178,240 +28247,251 @@ var TypeScript; } }; } - Parameters.fromParameterList = fromParameterList; - })(TypeScript.Parameters || (TypeScript.Parameters = {})); - var Parameters = TypeScript.Parameters; + ASTHelpers.parametersFromParameterList = parametersFromParameterList; - function isDeclarationAST(ast) { - switch (ast.kind()) { - case 225 /* VariableDeclarator */: - return getVariableStatement(ast) !== null; + function isDeclarationAST(ast) { + switch (ast.kind()) { + case 225 /* VariableDeclarator */: + return getVariableStatement(ast) !== null; - case 133 /* ImportDeclaration */: - case 131 /* ClassDeclaration */: - case 128 /* InterfaceDeclaration */: - case 242 /* Parameter */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 144 /* IndexSignature */: - case 129 /* FunctionDeclaration */: - case 130 /* ModuleDeclaration */: - case 124 /* ArrayType */: - case 122 /* ObjectType */: - case 238 /* TypeParameter */: - case 137 /* ConstructorDeclaration */: - case 135 /* MemberFunctionDeclaration */: - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - case 136 /* MemberVariableDeclaration */: - case 138 /* IndexMemberDeclaration */: - case 132 /* EnumDeclaration */: - case 243 /* EnumElement */: - case 240 /* SimplePropertyAssignment */: - case 241 /* FunctionPropertyAssignment */: - case 222 /* FunctionExpression */: - case 142 /* CallSignature */: - case 143 /* ConstructSignature */: - case 145 /* MethodSignature */: - case 141 /* PropertySignature */: - return true; - default: - return false; + case 133 /* ImportDeclaration */: + case 131 /* ClassDeclaration */: + case 128 /* InterfaceDeclaration */: + case 242 /* Parameter */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 144 /* IndexSignature */: + case 129 /* FunctionDeclaration */: + case 130 /* ModuleDeclaration */: + case 124 /* ArrayType */: + case 122 /* ObjectType */: + case 238 /* TypeParameter */: + case 137 /* ConstructorDeclaration */: + case 135 /* MemberFunctionDeclaration */: + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + case 136 /* MemberVariableDeclaration */: + case 138 /* IndexMemberDeclaration */: + case 132 /* EnumDeclaration */: + case 243 /* EnumElement */: + case 240 /* SimplePropertyAssignment */: + case 241 /* FunctionPropertyAssignment */: + case 222 /* FunctionExpression */: + case 142 /* CallSignature */: + case 143 /* ConstructSignature */: + case 145 /* MethodSignature */: + case 141 /* PropertySignature */: + return true; + default: + return false; + } } - } - TypeScript.isDeclarationAST = isDeclarationAST; + ASTHelpers.isDeclarationAST = isDeclarationAST; - function docComments(ast) { - if (isDeclarationAST(ast)) { - var preComments = ast.kind() === 225 /* VariableDeclarator */ ? getVariableStatement(ast).preComments() : ast.preComments(); + function docComments(ast) { + if (isDeclarationAST(ast)) { + var preComments = ast.kind() === 225 /* VariableDeclarator */ ? getVariableStatement(ast).preComments() : ast.preComments(); - if (preComments && preComments.length > 0) { - var preCommentsLength = preComments.length; - var docComments = new Array(); - for (var i = preCommentsLength - 1; i >= 0; i--) { - if (isDocComment(preComments[i])) { - docComments.push(preComments[i]); - continue; + if (preComments && preComments.length > 0) { + var preCommentsLength = preComments.length; + var docComments = new Array(); + for (var i = preCommentsLength - 1; i >= 0; i--) { + if (isDocComment(preComments[i])) { + docComments.push(preComments[i]); + continue; + } + + break; } - break; + return docComments.reverse(); + } + } + + return TypeScript.sentinelEmptyArray; + } + ASTHelpers.docComments = docComments; + + function isDocComment(comment) { + if (comment.kind() === 6 /* MultiLineCommentTrivia */) { + var fullText = comment.fullText(); + return fullText.charAt(2) === "*" && fullText.charAt(3) !== "/"; + } + + return false; + } + + function getParameterList(ast) { + if (ast) { + switch (ast.kind()) { + case 137 /* ConstructorDeclaration */: + return getParameterList(ast.callSignature); + case 129 /* FunctionDeclaration */: + return getParameterList(ast.callSignature); + case 218 /* ParenthesizedArrowFunctionExpression */: + return getParameterList(ast.callSignature); + case 143 /* ConstructSignature */: + return getParameterList(ast.callSignature); + case 135 /* MemberFunctionDeclaration */: + return getParameterList(ast.callSignature); + case 241 /* FunctionPropertyAssignment */: + return getParameterList(ast.callSignature); + case 222 /* FunctionExpression */: + return getParameterList(ast.callSignature); + case 145 /* MethodSignature */: + return getParameterList(ast.callSignature); + case 125 /* ConstructorType */: + return ast.parameterList; + case 123 /* FunctionType */: + return ast.parameterList; + case 142 /* CallSignature */: + return ast.parameterList; + case 139 /* GetAccessor */: + return ast.parameterList; + case 140 /* SetAccessor */: + return ast.parameterList; + } + } + + return null; + } + ASTHelpers.getParameterList = getParameterList; + + function getType(ast) { + if (ast) { + switch (ast.kind()) { + case 129 /* FunctionDeclaration */: + return getType(ast.callSignature); + case 218 /* ParenthesizedArrowFunctionExpression */: + return getType(ast.callSignature); + case 143 /* ConstructSignature */: + return getType(ast.callSignature); + case 135 /* MemberFunctionDeclaration */: + return getType(ast.callSignature); + case 241 /* FunctionPropertyAssignment */: + return getType(ast.callSignature); + case 222 /* FunctionExpression */: + return getType(ast.callSignature); + case 145 /* MethodSignature */: + return getType(ast.callSignature); + case 142 /* CallSignature */: + return getType(ast.typeAnnotation); + case 144 /* IndexSignature */: + return getType(ast.typeAnnotation); + case 141 /* PropertySignature */: + return getType(ast.typeAnnotation); + case 139 /* GetAccessor */: + return getType(ast.typeAnnotation); + case 242 /* Parameter */: + return getType(ast.typeAnnotation); + case 136 /* MemberVariableDeclaration */: + return getType(ast.variableDeclarator); + case 225 /* VariableDeclarator */: + return getType(ast.typeAnnotation); + case 236 /* CatchClause */: + return getType(ast.typeAnnotation); + case 125 /* ConstructorType */: + return ast.type; + case 123 /* FunctionType */: + return ast.type; + case 244 /* TypeAnnotation */: + return ast.type; + } + } + + return null; + } + ASTHelpers.getType = getType; + + function getVariableStatement(variableDeclarator) { + if (variableDeclarator && variableDeclarator.parent && variableDeclarator.parent.parent && variableDeclarator.parent.parent.parent && variableDeclarator.parent.kind() === 2 /* SeparatedList */ && variableDeclarator.parent.parent.kind() === 224 /* VariableDeclaration */ && variableDeclarator.parent.parent.parent.kind() === 148 /* VariableStatement */) { + return variableDeclarator.parent.parent.parent; + } + + return null; + } + + function getVariableDeclaratorModifiers(variableDeclarator) { + var variableStatement = getVariableStatement(variableDeclarator); + return variableStatement ? variableStatement.modifiers : TypeScript.sentinelEmptyArray; + } + ASTHelpers.getVariableDeclaratorModifiers = getVariableDeclaratorModifiers; + + function isIntegerLiteralAST(expression) { + if (expression) { + switch (expression.kind()) { + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + expression = expression.operand; + return expression.kind() === 13 /* NumericLiteral */ && TypeScript.IntegerUtilities.isInteger(expression.text()); + + case 13 /* NumericLiteral */: + var text = expression.text(); + return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); + } + } + + return false; + } + ASTHelpers.isIntegerLiteralAST = isIntegerLiteralAST; + + function getEnclosingModuleDeclaration(ast) { + while (ast) { + if (ast.kind() === 130 /* ModuleDeclaration */) { + return ast; } - return docComments.reverse(); - } - } - - return TypeScript.sentinelEmptyArray; - } - TypeScript.docComments = docComments; - - function isDocComment(comment) { - if (comment.kind() === 6 /* MultiLineCommentTrivia */) { - var fullText = comment.fullText(); - return fullText.charAt(2) === "*" && fullText.charAt(3) !== "/"; - } - - return false; - } - - function getParameterList(ast) { - if (ast) { - switch (ast.kind()) { - case 137 /* ConstructorDeclaration */: - return ast.parameterList; - case 129 /* FunctionDeclaration */: - return getParameterList(ast.callSignature); - case 218 /* ParenthesizedArrowFunctionExpression */: - return getParameterList(ast.callSignature); - case 143 /* ConstructSignature */: - return getParameterList(ast.callSignature); - case 135 /* MemberFunctionDeclaration */: - return getParameterList(ast.callSignature); - case 241 /* FunctionPropertyAssignment */: - return getParameterList(ast.callSignature); - case 222 /* FunctionExpression */: - return getParameterList(ast.callSignature); - case 145 /* MethodSignature */: - return getParameterList(ast.callSignature); - case 125 /* ConstructorType */: - return ast.parameterList; - case 123 /* FunctionType */: - return ast.parameterList; - case 142 /* CallSignature */: - return ast.parameterList; - case 139 /* GetAccessor */: - return ast.parameterList; - case 140 /* SetAccessor */: - return ast.parameterList; - } - } - - return null; - } - TypeScript.getParameterList = getParameterList; - - function getType(ast) { - if (ast) { - switch (ast.kind()) { - case 129 /* FunctionDeclaration */: - return getType(ast.callSignature); - case 218 /* ParenthesizedArrowFunctionExpression */: - return getType(ast.callSignature); - case 143 /* ConstructSignature */: - return getType(ast.callSignature); - case 135 /* MemberFunctionDeclaration */: - return getType(ast.callSignature); - case 241 /* FunctionPropertyAssignment */: - return getType(ast.callSignature); - case 222 /* FunctionExpression */: - return getType(ast.callSignature); - case 145 /* MethodSignature */: - return getType(ast.callSignature); - case 142 /* CallSignature */: - return getType(ast.typeAnnotation); - case 144 /* IndexSignature */: - return getType(ast.typeAnnotation); - case 141 /* PropertySignature */: - return getType(ast.typeAnnotation); - case 139 /* GetAccessor */: - return getType(ast.typeAnnotation); - case 242 /* Parameter */: - return getType(ast.typeAnnotation); - case 136 /* MemberVariableDeclaration */: - return getType(ast.variableDeclarator); - case 225 /* VariableDeclarator */: - return getType(ast.typeAnnotation); - case 236 /* CatchClause */: - return getType(ast.typeAnnotation); - case 125 /* ConstructorType */: - return ast.type; - case 123 /* FunctionType */: - return ast.type; - case 244 /* TypeAnnotation */: - return ast.type; - } - } - - return null; - } - TypeScript.getType = getType; - - function getVariableStatement(variableDeclarator) { - if (variableDeclarator && variableDeclarator.parent && variableDeclarator.parent.parent && variableDeclarator.parent.parent.parent && variableDeclarator.parent.kind() === 2 /* SeparatedList */ && variableDeclarator.parent.parent.kind() === 224 /* VariableDeclaration */ && variableDeclarator.parent.parent.parent.kind() === 148 /* VariableStatement */) { - return variableDeclarator.parent.parent.parent; - } - - return null; - } - - function getVariableDeclaratorModifiers(variableDeclarator) { - var variableStatement = getVariableStatement(variableDeclarator); - return variableStatement ? variableStatement.modifiers : TypeScript.sentinelEmptyArray; - } - TypeScript.getVariableDeclaratorModifiers = getVariableDeclaratorModifiers; - - function isIntegerLiteralAST(expression) { - if (expression) { - switch (expression.kind()) { - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - expression = expression.operand; - return expression.kind() === 13 /* NumericLiteral */ && TypeScript.IntegerUtilities.isInteger(expression.text()); - - case 13 /* NumericLiteral */: - var text = expression.text(); - return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); - } - } - - return false; - } - TypeScript.isIntegerLiteralAST = isIntegerLiteralAST; - - function getEnclosingModuleDeclaration(ast) { - while (ast) { - if (ast.kind() === 130 /* ModuleDeclaration */) { - return ast; + ast = ast.parent; } - ast = ast.parent; + return null; } + ASTHelpers.getEnclosingModuleDeclaration = getEnclosingModuleDeclaration; - return null; - } - TypeScript.getEnclosingModuleDeclaration = getEnclosingModuleDeclaration; + function isLastNameOfModule(ast, astName) { + if (ast) { + if (ast.stringLiteral) { + return astName === ast.stringLiteral; + } else { + var moduleNames = TypeScript.getModuleNames(ast.name); + var nameIndex = moduleNames.indexOf(astName); - function isLastNameOfModule(ast, astName) { - if (ast) { - if (ast.stringLiteral) { - return astName === ast.stringLiteral; + return nameIndex === (moduleNames.length - 1); + } + } + + return false; + } + ASTHelpers.isLastNameOfModule = isLastNameOfModule; + + function isAnyNameOfModule(ast, astName) { + if (ast) { + if (ast.stringLiteral) { + return ast.stringLiteral === astName; + } else { + var moduleNames = TypeScript.getModuleNames(ast.name); + var nameIndex = moduleNames.indexOf(astName); + + return nameIndex >= 0; + } + } + + return false; + } + ASTHelpers.isAnyNameOfModule = isAnyNameOfModule; + + function getNameOfIdenfierOrQualifiedName(name) { + if (name.kind() === 11 /* IdentifierName */) { + return name.text(); } else { - var moduleNames = TypeScript.getModuleNames(ast.name); - var nameIndex = moduleNames.indexOf(astName); - - return nameIndex === (moduleNames.length - 1); + TypeScript.Debug.assert(name.kind() == 121 /* QualifiedName */); + var dotExpr = name; + return getNameOfIdenfierOrQualifiedName(dotExpr.left) + "." + getNameOfIdenfierOrQualifiedName(dotExpr.right); } } - - return false; - } - TypeScript.isLastNameOfModule = isLastNameOfModule; - - function isAnyNameOfModule(ast, astName) { - if (ast) { - if (ast.stringLiteral) { - return ast.stringLiteral === astName; - } else { - var moduleNames = TypeScript.getModuleNames(ast.name); - var nameIndex = moduleNames.indexOf(astName); - - return nameIndex >= 0; - } - } - - return false; - } - TypeScript.isAnyNameOfModule = isAnyNameOfModule; + ASTHelpers.getNameOfIdenfierOrQualifiedName = getNameOfIdenfierOrQualifiedName; + })(TypeScript.ASTHelpers || (TypeScript.ASTHelpers = {})); + var ASTHelpers = TypeScript.ASTHelpers; })(TypeScript || (TypeScript = {})); var TypeScript; (function (TypeScript) { @@ -28619,7 +28699,7 @@ var TypeScript; } function walkConstructorDeclarationChildren(preAst, walker) { - walker.walk(preAst.parameterList); + walker.walk(preAst.callSignature); walker.walk(preAst.block); } @@ -29412,9 +29492,17 @@ var TypeScript; var settings = compiler.compilationSettings(); this._settings = settings; - if (settings.moduleGenTarget() === 0 /* Unspecified */ && compiler._isDynamicModuleCompilation()) { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Cannot_compile_external_modules_unless_the_module_flag_is_provided, null); - return; + if (settings.moduleGenTarget() === 0 /* Unspecified */) { + var fileNames = compiler.fileNames(); + for (var i = 0, n = fileNames.length; i < n; i++) { + var document = compiler.getDocument(fileNames[i]); + if (!document.isDeclareFile() && document.isExternalModule()) { + var errorSpan = document.externalModuleIndicatorSpan(); + this._diagnostic = new TypeScript.Diagnostic(document.fileName, document.lineMap(), errorSpan.start(), errorSpan.length(), TypeScript.DiagnosticCode.Cannot_compile_external_modules_unless_the_module_flag_is_provided); + + return; + } + } } if (!settings.mapSourceFiles()) { @@ -29496,7 +29584,7 @@ var TypeScript; updatedPath = true; if (j === 0) { - if (this._outputDirectory || this._sourceRootDirectory || (this._sourceMapRootDirectory && (!this._sharedOutputFile || compiler._isDynamicModuleCompilation()))) { + if (this._outputDirectory || this._sourceMapRootDirectory) { this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Cannot_find_the_common_subdirectory_path_for_the_input_files, null); return; } @@ -29573,10 +29661,10 @@ var TypeScript; this.sourceMapper = null; this.captureThisStmtString = "var _this = this;"; this.declStack = []; - this.exportAssignmentIdentifier = null; + this.exportAssignment = null; this.inWithBlock = false; this.document = null; - this.copyrightElement = null; + this.detachedCommentsElement = null; } Emitter.prototype.pushDecl = function (decl) { if (decl) { @@ -29596,12 +29684,12 @@ var TypeScript; return enclosingDecl; }; - Emitter.prototype.setExportAssignmentIdentifier = function (id) { - this.exportAssignmentIdentifier = id; + Emitter.prototype.setExportAssignment = function (exportAssignment) { + this.exportAssignment = exportAssignment; }; - Emitter.prototype.getExportAssignmentIdentifier = function () { - return this.exportAssignmentIdentifier; + Emitter.prototype.getExportAssignment = function () { + return this.exportAssignment; }; Emitter.prototype.setDocument = function (document) { @@ -29609,14 +29697,46 @@ var TypeScript; }; Emitter.prototype.shouldEmitImportDeclaration = function (importDeclAST) { - return TypeScript.importDeclarationIsElided(importDeclAST, this.semanticInfoChain, this.emitOptions.compilationSettings()); + var isExternalModuleReference = importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */; + var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST); + var isExported = TypeScript.hasFlag(importDecl.flags, 1 /* Exported */); + var isAmdCodeGen = this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */; + + if (isExternalModuleReference && !isExported && isAmdCodeGen) { + return false; + } + + var importSymbol = importDecl.getSymbol(); + if (importSymbol.isUsedAsValue()) { + return true; + } + + if (importDeclAST.moduleReference.kind() !== 245 /* ExternalModuleReference */) { + var canBeUsedExternally = isExported || importSymbol.typeUsedExternally() || importSymbol.isUsedInExportedAlias(); + if (!canBeUsedExternally && !this.document.isExternalModule()) { + canBeUsedExternally = TypeScript.hasFlag(importDecl.getParentDecl().kind, 1 /* Script */ | 32 /* DynamicModule */); + } + + if (canBeUsedExternally) { + if (importSymbol.getExportAssignedValueSymbol()) { + return true; + } + + var containerSymbol = importSymbol.getExportAssignedContainerSymbol(); + if (containerSymbol && containerSymbol.getInstanceSymbol()) { + return true; + } + } + } + + return false; }; Emitter.prototype.emitImportDeclaration = function (importDeclAST) { var isExternalModuleReference = importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */; var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST); var isExported = TypeScript.hasFlag(importDecl.flags, 1 /* Exported */); - var isAmdCodeGen = this.emitOptions.compilationSettings().moduleGenTarget() == 2 /* Asynchronous */; + var isAmdCodeGen = this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */; this.emitComments(importDeclAST, true); @@ -29631,12 +29751,12 @@ var TypeScript; var usePropertyAssignmentInsteadOfVarDecl = false; var moduleNamePrefix; - if (isExported && (parentKind == 4 /* Container */ || parentKind === 32 /* DynamicModule */ || associatedParentSymbolKind === 4 /* Container */ || associatedParentSymbolKind === 32 /* DynamicModule */)) { + if (isExported && (parentKind === 4 /* Container */ || parentKind === 32 /* DynamicModule */ || associatedParentSymbolKind === 4 /* Container */ || associatedParentSymbolKind === 32 /* DynamicModule */)) { if (importSymbol.getExportAssignedTypeSymbol() || importSymbol.getExportAssignedContainerSymbol()) { needsPropertyAssignment = true; } else { var valueSymbol = importSymbol.getExportAssignedValueSymbol(); - if (valueSymbol && (valueSymbol.kind == 65536 /* Method */ || valueSymbol.kind == 16384 /* Function */)) { + if (valueSymbol && (valueSymbol.kind === 65536 /* Method */ || valueSymbol.kind === 16384 /* Function */)) { needsPropertyAssignment = true; } else { usePropertyAssignmentInsteadOfVarDecl = true; @@ -29783,14 +29903,14 @@ var TypeScript; this.writeLineToOutput(""); } - if (!trailing && emitColumn != 0) { + if (!trailing && emitColumn !== 0) { this.emitIndent(); } }; Emitter.prototype.emitComments = function (ast, pre, onlyPinnedOrTripleSlashComments) { - if (typeof onlyPinnedOrTripleSlashComments === "undefined") { onlyPinnedOrTripleSlashComments = false; } var _this = this; + if (typeof onlyPinnedOrTripleSlashComments === "undefined") { onlyPinnedOrTripleSlashComments = false; } if (ast && ast.kind() !== 146 /* Block */) { if (ast.parent.kind() === 219 /* SimpleArrowFunctionExpression */ || ast.parent.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { return; @@ -29800,12 +29920,13 @@ var TypeScript; if (pre) { var preComments = ast.preComments(); - if (preComments && ast === this.copyrightElement) { - var copyrightComments = this.getCopyrightComments(); - preComments = preComments.slice(copyrightComments.length); + if (preComments && ast === this.detachedCommentsElement) { + var detachedComments = this.getDetachedComments(ast); + preComments = preComments.slice(detachedComments.length); + this.detachedCommentsElement = null; } - if (onlyPinnedOrTripleSlashComments) { + if (preComments && onlyPinnedOrTripleSlashComments) { preComments = TypeScript.ArrayUtilities.where(preComments, function (c) { return _this.isPinnedOrTripleSlash(c); }); @@ -29946,7 +30067,7 @@ var TypeScript; Emitter.prototype.emitParameterList = function (list) { this.writeToOutput("("); this.emitCommentsArray(list.openParenTrailingComments, true); - this.emitFunctionParameters(TypeScript.Parameters.fromParameterList(list)); + this.emitFunctionParameters(TypeScript.ASTHelpers.parametersFromParameterList(list)); this.writeToOutput(")"); }; @@ -29984,15 +30105,19 @@ var TypeScript; this.indenter.increaseIndent(); - if (parameterList) { - this.emitDefaultValueAssignments(parameterList); - this.emitRestParameterInitializer(parameterList); + if (block) { + this.emitDetachedComments(block.statements); } if (this.shouldCaptureThis(funcDecl)) { this.writeCaptureThisStatement(funcDecl); } + if (parameterList) { + this.emitDefaultValueAssignments(parameterList); + this.emitRestParameterInitializer(parameterList); + } + if (block) { this.emitList(block.statements); this.emitCommentsArray(block.closeBraceLeadingComments, false); @@ -30243,12 +30368,24 @@ var TypeScript; return null; }; - Emitter.prototype.hasChildNameCollision = function (moduleName, childDecls) { + Emitter.prototype.hasChildNameCollision = function (moduleName, parentDecl) { var _this = this; + var childDecls = parentDecl.getChildDecls(); return TypeScript.ArrayUtilities.any(childDecls, function (childDecl) { - if (childDecl.name == moduleName) { - var childAST = _this.semanticInfoChain.getASTForDecl(childDecl); - if (_this.shouldEmit(childAST)) { + var childAST = _this.semanticInfoChain.getASTForDecl(childDecl); + + if (childDecl.kind != 67108864 /* EnumMember */ && _this.shouldEmit(childAST)) { + if (childDecl.name === moduleName) { + if (parentDecl.kind != 8 /* Class */) { + return true; + } + + if (!(childDecl.kind == 65536 /* Method */ || childDecl.kind == 4096 /* Property */ || childDecl.kind == 524288 /* SetAccessor */ || childDecl.kind == 262144 /* GetAccessor */)) { + return true; + } + } + + if (_this.hasChildNameCollision(moduleName, childDecl)) { return true; } } @@ -30261,10 +30398,8 @@ var TypeScript; var moduleDisplayName = moduleDecl.getDisplayName(); moduleDecl = this.getModuleDeclToVerifyChildNameCollision(moduleDecl, changeNameIfAnyDeclarationInContext); - if (moduleDecl) { - var childDecls = moduleDecl.getChildDecls(); - - while (this.hasChildNameCollision(moduleName, childDecls)) { + if (moduleDecl && moduleDecl.kind != 64 /* Enum */) { + while (this.hasChildNameCollision(moduleName, moduleDecl)) { moduleName = "_" + moduleName; moduleDisplayName = "_" + moduleDisplayName; } @@ -30283,7 +30418,7 @@ var TypeScript; }; Emitter.prototype.emitSingleModuleDeclaration = function (moduleDecl, moduleName) { - var isLastName = TypeScript.isLastNameOfModule(moduleDecl, moduleName); + var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDecl, moduleName); if (isLastName) { this.emitComments(moduleDecl, true); @@ -30444,11 +30579,11 @@ var TypeScript; }; Emitter.prototype.emitSimpleArrowFunctionExpression = function (arrowFunction) { - this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.Parameters.fromIdentifier(arrowFunction.identifier), arrowFunction.block, arrowFunction.expression); + this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), arrowFunction.block, arrowFunction.expression); }; Emitter.prototype.emitParenthesizedArrowFunctionExpression = function (arrowFunction) { - this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.Parameters.fromParameterList(arrowFunction.callSignature.parameterList), arrowFunction.block, arrowFunction.expression); + this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromParameterList(arrowFunction.callSignature.parameterList), arrowFunction.block, arrowFunction.expression); }; Emitter.prototype.emitAnyArrowFunctionExpression = function (arrowFunction, funcName, parameters, block, expression) { @@ -30500,7 +30635,7 @@ var TypeScript; this.writeToOutput("function "); this.writeToOutput(this.thisClassNode.identifier.text()); this.writeToOutput("("); - var parameters = TypeScript.Parameters.fromParameterList(funcDecl.parameterList); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); this.emitFunctionParameters(parameters); this.writeLineToOutput(") {"); @@ -30554,7 +30689,7 @@ var TypeScript; this.writeToOutput("("); this.writeToOutput(")"); - this.emitFunctionBodyStatements(null, accessor, TypeScript.Parameters.fromParameterList(accessor.parameterList), accessor.block, null); + this.emitFunctionBodyStatements(null, accessor, TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList), accessor.block, null); this.recordSourceMappingEnd(accessor); @@ -30586,7 +30721,7 @@ var TypeScript; this.writeToOutput(accessor.propertyName.text()); this.writeToOutput("("); - var parameters = TypeScript.Parameters.fromParameterList(accessor.parameterList); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList); this.emitFunctionParameters(parameters); this.writeToOutput(")"); @@ -30625,7 +30760,7 @@ var TypeScript; this.writeToOutput("("); - var parameters = TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); this.emitFunctionParameters(parameters); this.writeToOutput(")"); @@ -30680,7 +30815,7 @@ var TypeScript; this.emitParameterList(funcDecl.callSignature.parameterList); - var parameters = TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); this.emitFunctionBodyStatements(funcDecl.identifier.text(), funcDecl, parameters, funcDecl.block, null); this.recordSourceMappingEnd(funcDecl); @@ -30953,7 +31088,7 @@ var TypeScript; if (pullSymbol && pullSymbolAlias) { var symbolToCompare = TypeScript.isTypesOnlyLocation(ast) ? pullSymbolAlias.getExportAssignedTypeSymbol() : pullSymbolAlias.getExportAssignedValueSymbol(); - if (pullSymbol == symbolToCompare) { + if (pullSymbol === symbolToCompare) { pullSymbol = pullSymbolAlias; pullSymbolAlias = null; } @@ -30972,7 +31107,7 @@ var TypeScript; } var pullSymbolAlias = symbolForEmit.aliasSymbol; var pullSymbolKind = pullSymbol.kind; - var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() == this.getEnclosingDecl()); + var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() === this.getEnclosingDecl()); if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { var pullSymbolContainer = pullSymbol.getContainer(); @@ -31017,19 +31152,19 @@ var TypeScript; if (name) { if (this.sourceMapper.currentNameIndex.length > 0) { var parentNameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; - if (parentNameIndex != -1) { + if (parentNameIndex !== -1) { name = this.sourceMapper.names[parentNameIndex] + "." + name; } } var nameIndex = this.sourceMapper.names.length - 1; for (nameIndex; nameIndex >= 0; nameIndex--) { - if (this.sourceMapper.names[nameIndex] == name) { + if (this.sourceMapper.names[nameIndex] === name) { break; } } - if (nameIndex == -1) { + if (nameIndex === -1) { nameIndex = this.sourceMapper.names.length; this.sourceMapper.names.push(name); } @@ -31045,7 +31180,7 @@ var TypeScript; }; Emitter.prototype.recordSourceMappingStart = function (ast) { - if (this.sourceMapper && TypeScript.isValidAstNode(ast)) { + if (this.sourceMapper && TypeScript.ASTHelpers.isValidAstNode(ast)) { var lineCol = { line: -1, character: -1 }; var sourceMapping = new TypeScript.SourceMapping(); sourceMapping.start.emittedColumn = this.emitState.column; @@ -31078,7 +31213,7 @@ var TypeScript; }; Emitter.prototype.recordSourceMappingEnd = function (ast) { - if (this.sourceMapper && TypeScript.isValidAstNode(ast)) { + if (this.sourceMapper && TypeScript.ASTHelpers.isValidAstNode(ast)) { this.sourceMapper.currentMappings.pop(); var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; @@ -31108,9 +31243,9 @@ var TypeScript; Emitter.prototype.emitParameterPropertyAndMemberVariableAssignments = function () { var constructorDecl = getLastConstructor(this.thisClassNode); - if (constructorDecl && constructorDecl.parameterList) { - for (var i = 0, n = constructorDecl.parameterList.parameters.nonSeparatorCount(); i < n; i++) { - var parameter = constructorDecl.parameterList.parameters.nonSeparatorAt(i); + if (constructorDecl) { + for (var i = 0, n = constructorDecl.callSignature.parameterList.parameters.nonSeparatorCount(); i < n; i++) { + var parameter = constructorDecl.callSignature.parameterList.parameters.nonSeparatorAt(i); var parameterDecl = this.semanticInfoChain.getDeclForAST(parameter); if (TypeScript.hasFlag(parameterDecl.flags, 8388608 /* PropertyParameter */)) { this.emitIndent(); @@ -31270,12 +31405,12 @@ var TypeScript; } }; - Emitter.prototype.getCopyrightComments = function () { - var preComments = this.copyrightElement.preComments(); + Emitter.prototype.getDetachedComments = function (element) { + var preComments = element.preComments(); if (preComments) { var lineMap = this.document.lineMap(); - var copyrightComments = []; + var detachedComments = []; var lastComment = null; for (var i = 0, n = preComments.length; i < n; i++) { @@ -31286,18 +31421,18 @@ var TypeScript; var commentLine = lineMap.getLineNumberFromPosition(comment.start()); if (commentLine >= lastCommentLine + 2) { - return copyrightComments; + return detachedComments; } } - copyrightComments.push(comment); + detachedComments.push(comment); lastComment = comment; } - var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(copyrightComments).end()); - var astLine = lineMap.getLineNumberFromPosition(this.copyrightElement.start()); + var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(detachedComments).end()); + var astLine = lineMap.getLineNumberFromPosition(element.start()); if (astLine >= lastCommentLine + 2) { - return copyrightComments; + return detachedComments; } } @@ -31305,12 +31440,15 @@ var TypeScript; }; Emitter.prototype.emitPossibleCopyrightHeaders = function (script) { - var list = script.moduleElements; + this.emitDetachedComments(script.moduleElements); + }; + + Emitter.prototype.emitDetachedComments = function (list) { if (list.childCount() > 0) { var firstElement = list.childAt(0); - this.copyrightElement = firstElement; - this.emitCommentsArray(this.getCopyrightComments(), false); + this.detachedCommentsElement = firstElement; + this.emitCommentsArray(this.getDetachedComments(this.detachedCommentsElement), false); } }; @@ -31333,7 +31471,7 @@ var TypeScript; this.emitPrologue(sourceUnit); var isExternalModule = this.document.isExternalModule(); - var isNonElidedExternalModule = isExternalModule && !TypeScript.scriptIsElided(sourceUnit); + var isNonElidedExternalModule = isExternalModule && !TypeScript.ASTHelpers.scriptIsElided(sourceUnit); if (isNonElidedExternalModule) { this.recordSourceMappingStart(sourceUnit); @@ -31358,7 +31496,7 @@ var TypeScript; this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); } - this.setExportAssignmentIdentifier(null); + this.setExportAssignment(null); if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { this.indenter.increaseIndent(); @@ -31381,20 +31519,23 @@ var TypeScript; } if (isNonElidedExternalModule) { - var exportAssignmentIdentifier = this.getExportAssignmentIdentifier(); + var exportAssignment = this.getExportAssignment(); + var exportAssignmentIdentifierText = exportAssignment ? exportAssignment.identifier.text() : null; var exportAssignmentValueSymbol = externalModule.getSymbol().getExportAssignedValueSymbol(); if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - if (exportAssignmentIdentifier && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { + if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { this.indenter.increaseIndent(); this.emitIndent(); - this.writeLineToOutput("return " + exportAssignmentIdentifier + ";"); + this.writeToOutputWithSourceMapRecord("return " + exportAssignmentIdentifierText, exportAssignment); + this.writeLineToOutput(";"); this.indenter.decreaseIndent(); } this.writeToOutput("});"); - } else if (exportAssignmentIdentifier && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { + } else if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { this.emitIndent(); - this.writeToOutput("module.exports = " + exportAssignmentIdentifier + ";"); + this.writeToOutputWithSourceMapRecord("module.exports = " + exportAssignmentIdentifierText, exportAssignment); + this.writeToOutput(";"); } this.recordSourceMappingEnd(sourceUnit); @@ -31416,7 +31557,7 @@ var TypeScript; this.emitComments(list, true); - var emitPropertyAssignmentsAfterSuperCall = TypeScript.getExtendsHeritageClause(this.thisClassNode.heritageClauses) !== null; + var emitPropertyAssignmentsAfterSuperCall = TypeScript.ASTHelpers.getExtendsHeritageClause(this.thisClassNode.heritageClauses) !== null; var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; var lastEmittedNode = null; @@ -31523,7 +31664,7 @@ var TypeScript; this.writeToOutput("("); - var parameters = TypeScript.Parameters.fromParameterList(parameterList); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(parameterList); this.emitFunctionParameters(parameters); this.writeToOutput(")"); @@ -31548,7 +31689,7 @@ var TypeScript; this.recordSourceMappingStart(classDecl); this.writeToOutput("var " + className); - var hasBaseClass = TypeScript.getExtendsHeritageClause(classDecl.heritageClauses) !== null; + var hasBaseClass = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses) !== null; var baseTypeReference = null; var varDecl = null; @@ -31562,9 +31703,10 @@ var TypeScript; this.indenter.increaseIndent(); if (hasBaseClass) { - baseTypeReference = TypeScript.getExtendsHeritageClause(classDecl.heritageClauses).typeNames.nonSeparatorAt(0); + baseTypeReference = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses).typeNames.nonSeparatorAt(0); this.emitIndent(); - this.writeLineToOutput("__extends(" + className + ", _super);"); + this.writeToOutputWithSourceMapRecord("__extends(" + className + ", _super)", baseTypeReference); + this.writeLineToOutput(";"); } this.emitIndent(); @@ -31582,7 +31724,8 @@ var TypeScript; this.recordSourceMappingNameStart("constructor"); if (hasBaseClass) { this.emitIndent(); - this.writeLineToOutput("_super.apply(this, arguments);"); + this.writeToOutputWithSourceMapRecord("_super.apply(this, arguments)", baseTypeReference); + this.writeLineToOutput(";"); } if (this.shouldCaptureThis(classDecl)) { @@ -31593,7 +31736,8 @@ var TypeScript; this.indenter.decreaseIndent(); this.emitIndent(); - this.writeLineToOutput("}"); + this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); + this.writeLineToOutput(""); this.recordSourceMappingNameEnd(); this.recordSourceMappingEnd(classDecl); @@ -31715,7 +31859,7 @@ var TypeScript; this.emitParameterList(funcDecl.callSignature.parameterList); - var parameters = TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); this.emitFunctionBodyStatements(funcDecl.propertyName.text(), funcDecl, parameters, funcDecl.block, null); this.recordSourceMappingEnd(funcDecl); @@ -31741,7 +31885,7 @@ var TypeScript; } else if (moduleElement.kind() === 131 /* ClassDeclaration */) { var classDeclaration = moduleElement; - if (!TypeScript.hasModifier(classDeclaration.modifiers, 8 /* Ambient */) && TypeScript.getExtendsHeritageClause(classDeclaration.heritageClauses) !== null) { + if (!TypeScript.hasModifier(classDeclaration.modifiers, 8 /* Ambient */) && TypeScript.ASTHelpers.getExtendsHeritageClause(classDeclaration.heritageClauses) !== null) { return true; } } @@ -31921,13 +32065,13 @@ var TypeScript; Emitter.prototype.canEmitDottedNameMemberAccessExpression = function (expression) { var memberExpressionNodeType = expression.expression.kind(); - if (memberExpressionNodeType == 11 /* IdentifierName */ || memberExpressionNodeType == 212 /* MemberAccessExpression */) { + if (memberExpressionNodeType === 11 /* IdentifierName */ || memberExpressionNodeType == 212 /* MemberAccessExpression */) { var memberAccessSymbol = this.getSymbolForEmit(expression).symbol; var memberAccessExpressionSymbol = this.getSymbolForEmit(expression.expression).symbol; if (memberAccessSymbol && memberAccessExpressionSymbol && !this.semanticInfoChain.getAliasSymbolForAST(expression.expression) && (TypeScript.PullHelpers.symbolIsModule(memberAccessExpressionSymbol) || memberAccessExpressionSymbol.kind === 64 /* Enum */ || memberAccessExpressionSymbol.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */))) { var memberAccessSymbolKind = memberAccessSymbol.kind; if (memberAccessSymbolKind === 4096 /* Property */ || memberAccessSymbolKind === 67108864 /* EnumMember */ || (memberAccessSymbol.anyDeclHasFlag(1 /* Exported */) && memberAccessSymbolKind === 512 /* Variable */ && !memberAccessSymbol.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) || ((memberAccessSymbol.anyDeclHasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(memberAccessSymbol)))) { - if (memberExpressionNodeType == 212 /* MemberAccessExpression */) { + if (memberExpressionNodeType === 212 /* MemberAccessExpression */) { return this.canEmitDottedNameMemberAccessExpression(expression.expression); } @@ -31941,7 +32085,7 @@ var TypeScript; Emitter.prototype.emitDottedNameMemberAccessExpressionWorker = function (expression, potentialPath, startingIndex, lastIndex) { this.recordSourceMappingStart(expression); - if (expression.expression.kind() == 212 /* MemberAccessExpression */) { + if (expression.expression.kind() === 212 /* MemberAccessExpression */) { this.emitDottedNameMemberAccessExpressionRecurse(expression.expression, potentialPath, startingIndex, lastIndex - 1); } else { this.emitComments(expression.expression, true); @@ -32058,7 +32202,7 @@ var TypeScript; this.writeToOutput("("); - var parameters = TypeScript.Parameters.fromParameterList(funcProp.callSignature.parameterList); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcProp.callSignature.parameterList); this.emitFunctionParameters(parameters); this.writeToOutput(")"); @@ -32074,8 +32218,6 @@ var TypeScript; this.setContainer(temp); this.inArrowFunction = savedInArrowFunction; - - this.recordSourceMappingEnd(funcProp); }; Emitter.prototype.emitConditionalExpression = function (expression) { @@ -32396,15 +32538,17 @@ var TypeScript; this.pushDecl(pullDecl); this.emitScriptElements(sourceUnit); this.popDecl(pullDecl); + + this.emitCommentsArray(sourceUnit.endOfFileTokenLeadingComments, false); } }; Emitter.prototype.shouldEmitEnumDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.enumIsElided(declaration); + return declaration.preComments() !== null || !TypeScript.ASTHelpers.enumIsElided(declaration); }; Emitter.prototype.emitEnumDeclaration = function (declaration) { - if (!TypeScript.enumIsElided(declaration)) { + if (!TypeScript.ASTHelpers.enumIsElided(declaration)) { this.emitComments(declaration, true); this.emitEnum(declaration); this.emitComments(declaration, false); @@ -32414,11 +32558,11 @@ var TypeScript; }; Emitter.prototype.shouldEmitModuleDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.moduleIsElided(declaration); + return declaration.preComments() !== null || !TypeScript.ASTHelpers.moduleIsElided(declaration); }; Emitter.prototype.emitModuleDeclaration = function (declaration) { - if (!TypeScript.moduleIsElided(declaration)) { + if (!TypeScript.ASTHelpers.moduleIsElided(declaration)) { this.emitModuleDeclarationWorker(declaration); } else { this.emitComments(declaration, true, true); @@ -32514,7 +32658,7 @@ var TypeScript; case 133 /* ImportDeclaration */: return this.emitImportDeclaration(ast); case 134 /* ExportAssignment */: - return this.setExportAssignmentIdentifier(ast.identifier.text()); + return this.setExportAssignment(ast); case 131 /* ClassDeclaration */: return this.emitClassDeclaration(ast); case 128 /* InterfaceDeclaration */: @@ -33253,10 +33397,10 @@ var TypeScript; var dtsFile = normalizedPath + ".d.ts"; var tsFile = normalizedPath + ".ts"; - if (this.host.fileExists(dtsFile)) { - normalizedPath = dtsFile; - } else { + if (this.host.fileExists(tsFile)) { normalizedPath = tsFile; + } else { + normalizedPath = dtsFile; } } @@ -33286,13 +33430,13 @@ var TypeScript; var start = new Date().getTime(); do { - var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); + currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); if (this.host.fileExists(currentFilePath)) { searchFilePath = currentFilePath; break; } - currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); + var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); if (this.host.fileExists(currentFilePath)) { searchFilePath = currentFilePath; break; @@ -33544,7 +33688,7 @@ var TypeScript; var declAST = this.semanticInfoChain.getASTForDecl(pullDecl); var container = this.getEnclosingContainer(declAST); - if (container.kind() === 130 /* ModuleDeclaration */ && TypeScript.isAnyNameOfModule(container, declAST)) { + if (container.kind() === 130 /* ModuleDeclaration */ && TypeScript.ASTHelpers.isAnyNameOfModule(container, declAST)) { container = this.getEnclosingContainer(container); } @@ -33555,8 +33699,8 @@ var TypeScript; emitDeclare = true; } - if (isExternalModule || container.kind() == 120 /* SourceUnit */) { - if (emitDeclare && typeString !== "interface" && typeString != "import") { + if (isExternalModule || container.kind() === 120 /* SourceUnit */) { + if (emitDeclare && typeString !== "interface" && typeString !== "import") { result += "declare "; } } @@ -33625,7 +33769,9 @@ var TypeScript; var declarationPullSymbol = declarationContainerDecl.getSymbol(); TypeScript.declarationEmitTypeSignatureTime += new Date().getTime() - start; - var typeNameMembers = type.getScopedNameEx(declarationPullSymbol); + var isNotAGenericType = ast.kind() !== 126 /* GenericType */; + + var typeNameMembers = type.getScopedNameEx(declarationPullSymbol, false, false, false, false, false, isNotAGenericType); this.emitTypeNamesMember(typeNameMembers); }; @@ -33659,7 +33805,7 @@ var TypeScript; return; } - var declComments = astOrSymbol.docComments ? astOrSymbol.docComments() : TypeScript.docComments(astOrSymbol); + var declComments = astOrSymbol.docComments ? astOrSymbol.docComments() : TypeScript.ASTHelpers.docComments(astOrSymbol); this.writeDeclarationComments(declComments, endLine); }; @@ -33718,7 +33864,7 @@ var TypeScript; this.declFile.Write(varDecl.propertyName.text()); - if (!TypeScript.hasModifier(TypeScript.getVariableDeclaratorModifiers(varDecl), 2 /* Private */)) { + if (!TypeScript.hasModifier(TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl), 2 /* Private */)) { this.emitTypeOfVariableDeclaratorOrParameter(varDecl); } @@ -33770,7 +33916,7 @@ var TypeScript; DeclarationEmitter.prototype.emitDeclarationsForVariableDeclaration = function (variableDeclaration) { var varListCount = variableDeclaration.declarators.nonSeparatorCount(); for (var i = 0; i < varListCount; i++) { - this.emitVariableDeclarator(variableDeclaration.declarators.nonSeparatorAt(i), i == 0, i == varListCount - 1); + this.emitVariableDeclarator(variableDeclaration.declarators.nonSeparatorAt(i), i === 0, i === varListCount - 1); } }; @@ -33825,14 +33971,14 @@ var TypeScript; this.declFile.Write("constructor"); this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.parameterList)); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); this.declFile.Write(")"); this.declFile.WriteLine(";"); }; DeclarationEmitter.prototype.emitParameterList = function (isPrivate, parameterList) { this.declFile.Write("("); - this.emitParameters(isPrivate, TypeScript.Parameters.fromParameterList(parameterList)); + this.emitParameters(isPrivate, TypeScript.ASTHelpers.parametersFromParameterList(parameterList)); this.declFile.Write(")"); }; @@ -33923,7 +34069,7 @@ var TypeScript; this.emitIndent(); this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.parameterList)); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList)); this.declFile.Write(")"); var returnType = funcSignature.returnType; @@ -33954,7 +34100,7 @@ var TypeScript; this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList)); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); this.declFile.Write(")"); var returnType = funcSignature.returnType; @@ -33988,7 +34134,7 @@ var TypeScript; this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList)); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); this.declFile.Write(")"); var returnType = funcSignature.returnType; @@ -34038,7 +34184,7 @@ var TypeScript; this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList)); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); this.declFile.Write(")"); var returnType = funcSignature.returnType; @@ -34065,7 +34211,7 @@ var TypeScript; this.emitIndent(); this.declFile.Write("["); - this.emitParameters(false, TypeScript.Parameters.fromParameter(funcDecl.parameter)); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter)); this.declFile.Write("]"); var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); @@ -34104,10 +34250,10 @@ var TypeScript; var comments = []; if (accessors.getter) { - comments = comments.concat(TypeScript.docComments(accessors.getter)); + comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.getter)); } if (accessors.setter) { - comments = comments.concat(TypeScript.docComments(accessors.setter)); + comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.setter)); } this.writeDeclarationComments(comments); @@ -34144,27 +34290,25 @@ var TypeScript; }; DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { - if (funcDecl.parameterList) { - var argsLen = funcDecl.parameterList.parameters.nonSeparatorCount(); - if (TypeScript.lastParameterIsRest(funcDecl.parameterList)) { - argsLen--; - } + var argsLen = funcDecl.callSignature.parameterList.parameters.nonSeparatorCount(); + if (TypeScript.lastParameterIsRest(funcDecl.callSignature.parameterList)) { + argsLen--; + } - for (var i = 0; i < argsLen; i++) { - var parameter = funcDecl.parameterList.parameters.nonSeparatorAt(i); - var parameterDecl = this.semanticInfoChain.getDeclForAST(parameter); - if (TypeScript.hasFlag(parameterDecl.flags, 8388608 /* PropertyParameter */)) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.emitDeclarationComments(parameter); - this.declFile.Write(this.getIndentString()); - this.emitClassElementModifiers(parameter.modifiers); - this.declFile.Write(parameter.identifier.text()); + for (var i = 0; i < argsLen; i++) { + var parameter = funcDecl.callSignature.parameterList.parameters.nonSeparatorAt(i); + var parameterDecl = this.semanticInfoChain.getDeclForAST(parameter); + if (TypeScript.hasFlag(parameterDecl.flags, 8388608 /* PropertyParameter */)) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.emitDeclarationComments(parameter); + this.declFile.Write(this.getIndentString()); + this.emitClassElementModifiers(parameter.modifiers); + this.declFile.Write(parameter.identifier.text()); - if (!TypeScript.hasModifier(parameter.modifiers, 2 /* Private */)) { - this.emitTypeOfVariableDeclaratorOrParameter(parameter); - } - this.declFile.WriteLine(";"); + if (!TypeScript.hasModifier(parameter.modifiers, 2 /* Private */)) { + this.emitTypeOfVariableDeclaratorOrParameter(parameter); } + this.declFile.WriteLine(";"); } } }; @@ -34296,20 +34440,11 @@ var TypeScript; if (importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { this.declFile.WriteLine("require(" + importDeclAST.moduleReference.stringLiteral.text() + ");"); } else { - this.declFile.WriteLine(this.getFullName(importDeclAST.moduleReference.moduleName) + ";"); + this.declFile.WriteLine(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(importDeclAST.moduleReference.moduleName) + ";"); } } }; - DeclarationEmitter.prototype.getFullName = function (name) { - if (name.kind() === 11 /* IdentifierName */) { - return name.text(); - } else { - var dotExpr = name; - return this.getFullName(dotExpr.left) + "." + this.getFullName(dotExpr.right); - } - }; - DeclarationEmitter.prototype.emitDeclarationsForEnumDeclaration = function (moduleDecl) { if (!this.canEmitDeclarations(moduleDecl)) { return; @@ -34329,7 +34464,7 @@ var TypeScript; this.emitDeclarationComments(enumElement); this.emitIndent(); this.declFile.Write(enumElement.propertyName.text()); - if (enumElementDecl.constantValue != null) { + if (enumElementDecl.constantValue !== null) { this.declFile.Write(" = " + enumElementDecl.constantValue); } this.declFile.WriteLine(","); @@ -34354,7 +34489,7 @@ var TypeScript; if (moduleDecl.stringLiteral) { this.declFile.Write(moduleDecl.stringLiteral.text()); } else { - this.declFile.Write(this.getFullName(moduleDecl.name)); + this.declFile.Write(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(moduleDecl.name)); } this.declFile.WriteLine(" {"); @@ -34417,12 +34552,12 @@ var TypeScript; if (document && (document.isDeclareFile() || document.isExternalModule())) { for (var k = 0; k < documents.length; k++) { - if (documents[k] == document) { + if (documents[k] === document) { break; } } - if (k == documents.length) { + if (k === documents.length) { documents = documents.concat(document); } } @@ -34522,16 +34657,16 @@ var TypeScript; }; BloomFilter.prototype.isEquivalent = function (filter) { - return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount == filter.hashFunctionCount; + return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount === filter.hashFunctionCount; }; BloomFilter.isEquivalent = function (array1, array2) { - if (array1.length != array2.length) { + if (array1.length !== array2.length) { return false; } for (var i = 0; i < array1.length; i++) { - if (array1[i] != array2[i]) { + if (array1[i] !== array2[i]) { return false; } } @@ -34580,13 +34715,14 @@ var TypeScript; this.useCaseSensitiveFileResolution = false; this.gatherDiagnostics = false; this.codepage = null; + this.createFileLog = false; } return CompilationSettings; })(); TypeScript.CompilationSettings = CompilationSettings; var ImmutableCompilationSettings = (function () { - function ImmutableCompilationSettings(propagateEnumConstants, removeComments, watch, noResolve, allowAutomaticSemicolonInsertion, noImplicitAny, noLib, codeGenTarget, moduleGenTarget, outFileOption, outDirOption, mapSourceFiles, mapRoot, sourceRoot, generateDeclarationFiles, useCaseSensitiveFileResolution, gatherDiagnostics, codepage) { + function ImmutableCompilationSettings(propagateEnumConstants, removeComments, watch, noResolve, allowAutomaticSemicolonInsertion, noImplicitAny, noLib, codeGenTarget, moduleGenTarget, outFileOption, outDirOption, mapSourceFiles, mapRoot, sourceRoot, generateDeclarationFiles, useCaseSensitiveFileResolution, gatherDiagnostics, codepage, createFileLog) { this._propagateEnumConstants = propagateEnumConstants; this._removeComments = removeComments; this._watch = watch; @@ -34605,6 +34741,7 @@ var TypeScript; this._useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; this._gatherDiagnostics = gatherDiagnostics; this._codepage = codepage; + this._createFileLog = createFileLog; } ImmutableCompilationSettings.prototype.propagateEnumConstants = function () { return this._propagateEnumConstants; @@ -34660,6 +34797,9 @@ var TypeScript; ImmutableCompilationSettings.prototype.codepage = function () { return this._codepage; }; + ImmutableCompilationSettings.prototype.createFileLog = function () { + return this._createFileLog; + }; ImmutableCompilationSettings.defaultSettings = function () { if (!ImmutableCompilationSettings._defaultSettings) { @@ -34670,15 +34810,17 @@ var TypeScript; }; ImmutableCompilationSettings.fromCompilationSettings = function (settings) { - return new ImmutableCompilationSettings(settings.propagateEnumConstants, settings.removeComments, settings.watch, settings.noResolve, settings.allowAutomaticSemicolonInsertion, settings.noImplicitAny, settings.noLib, settings.codeGenTarget, settings.moduleGenTarget, settings.outFileOption, settings.outDirOption, settings.mapSourceFiles, settings.mapRoot, settings.sourceRoot, settings.generateDeclarationFiles, settings.useCaseSensitiveFileResolution, settings.gatherDiagnostics, settings.codepage); + return new ImmutableCompilationSettings(settings.propagateEnumConstants, settings.removeComments, settings.watch, settings.noResolve, settings.allowAutomaticSemicolonInsertion, settings.noImplicitAny, settings.noLib, settings.codeGenTarget, settings.moduleGenTarget, settings.outFileOption, settings.outDirOption, settings.mapSourceFiles, settings.mapRoot, settings.sourceRoot, settings.generateDeclarationFiles, settings.useCaseSensitiveFileResolution, settings.gatherDiagnostics, settings.codepage, settings.createFileLog); }; ImmutableCompilationSettings.prototype.toCompilationSettings = function () { var result = new CompilationSettings(); + var thisAsIndexable = this; + var resultAsIndexable = result; for (var name in this) { if (this.hasOwnProperty(name) && TypeScript.StringUtilities.startsWith(name, "_")) { - result[name.substr(1)] = this[name]; + resultAsIndexable[name.substr(1)] = thisAsIndexable[name]; } } @@ -34784,7 +34926,7 @@ var TypeScript; PullElementKind[PullElementKind["SomeValue"] = PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.EnumMember | PullElementKind.SomeFunction] = "SomeValue"; - PullElementKind[PullElementKind["SomeType"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Class | PullElementKind.Interface | PullElementKind.Enum | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.TypeParameter] = "SomeType"; + PullElementKind[PullElementKind["SomeType"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Class | PullElementKind.Interface | PullElementKind.Enum | PullElementKind.ObjectLiteral | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.TypeParameter] = "SomeType"; PullElementKind[PullElementKind["AcceptableAlias"] = PullElementKind.Variable | PullElementKind.SomeFunction | PullElementKind.Class | PullElementKind.Interface | PullElementKind.Enum | PullElementKind.Container | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "AcceptableAlias"; @@ -34800,17 +34942,18 @@ var TypeScript; })(TypeScript || (TypeScript = {})); var TypeScript; (function (TypeScript) { - TypeScript.pullDeclID = 0; + var pullDeclID = 0; var sentinelEmptyPullDeclArray = []; var PullDecl = (function () { - function PullDecl(declName, displayName, kind, declFlags, span) { - this.declID = TypeScript.pullDeclID++; + function PullDecl(declName, displayName, kind, declFlags, semanticInfoChain) { + this.declID = pullDeclID++; this.flags = 0 /* None */; this.declGroups = null; this.childDecls = null; this.typeParameters = null; this.synthesizedValDecl = null; + this.containerDecl = null; this.childDeclTypeCache = null; this.childDeclValueCache = null; this.childDeclNamespaceCache = null; @@ -34818,7 +34961,7 @@ var TypeScript; this.name = declName; this.kind = kind; this.flags = declFlags; - this.span = span; + this.semanticInfoChain = semanticInfoChain; if (displayName !== this.name) { this.declDisplayName = displayName; @@ -34836,10 +34979,6 @@ var TypeScript; throw TypeScript.Errors.abstract(); }; - PullDecl.prototype.semanticInfoChain = function () { - throw TypeScript.Errors.abstract(); - }; - PullDecl.prototype.isExternalModule = function () { throw TypeScript.Errors.abstract(); }; @@ -34872,44 +35011,42 @@ var TypeScript; }; PullDecl.prototype.setSymbol = function (symbol) { - this.semanticInfoChain().setSymbolForDecl(this, symbol); + this.semanticInfoChain.setSymbolForDecl(this, symbol); }; - PullDecl.prototype.ensureSymbolIsBound = function (bindSignatureSymbol) { - if (typeof bindSignatureSymbol === "undefined") { bindSignatureSymbol = false; } - if (!((bindSignatureSymbol && this.hasSignatureSymbol()) || this.hasSymbol()) && this.kind != 1 /* Script */) { - var binder = this.semanticInfoChain().getBinder(); + PullDecl.prototype.ensureSymbolIsBound = function () { + if (!this.hasBeenBound() && this.kind !== 1 /* Script */) { + var binder = this.semanticInfoChain.getBinder(); binder.bindDeclToPullSymbol(this); } }; PullDecl.prototype.getSymbol = function () { - if (this.kind == 1 /* Script */) { + if (this.kind === 1 /* Script */) { return null; } this.ensureSymbolIsBound(); - return this.semanticInfoChain().getSymbolForDecl(this); + return this.semanticInfoChain.getSymbolForDecl(this); }; PullDecl.prototype.hasSymbol = function () { - var symbol = this.semanticInfoChain().getSymbolForDecl(this); + var symbol = this.semanticInfoChain.getSymbolForDecl(this); return !!symbol; }; PullDecl.prototype.setSignatureSymbol = function (signatureSymbol) { - this.semanticInfoChain().setSignatureSymbolForDecl(this, signatureSymbol); + this.semanticInfoChain.setSignatureSymbolForDecl(this, signatureSymbol); }; PullDecl.prototype.getSignatureSymbol = function () { - this.ensureSymbolIsBound(true); - - return this.semanticInfoChain().getSignatureSymbolForDecl(this); + this.ensureSymbolIsBound(); + return this.semanticInfoChain.getSignatureSymbolForDecl(this); }; PullDecl.prototype.hasSignatureSymbol = function () { - var signatureSymbol = this.semanticInfoChain().getSignatureSymbolForDecl(this); + var signatureSymbol = this.semanticInfoChain.getSignatureSymbolForDecl(this); return !!signatureSymbol; }; @@ -34921,20 +35058,17 @@ var TypeScript; this.flags |= flags; }; - PullDecl.prototype.getSpan = function () { - return this.span; - }; - PullDecl.prototype.setValueDecl = function (valDecl) { this.synthesizedValDecl = valDecl; + valDecl.containerDecl = this; }; PullDecl.prototype.getValueDecl = function () { return this.synthesizedValDecl; }; - PullDecl.prototype.isEqual = function (other) { - return (this.name === other.name) && (this.kind === other.kind) && (this.flags === other.flags) && (this.fileName() === other.fileName()) && (this.span.start() === other.span.start()) && (this.span.end() === other.span.end()); + PullDecl.prototype.getContainerDecl = function () { + return this.containerDecl; }; PullDecl.prototype.getChildDeclCache = function (declKind) { @@ -34950,7 +35084,7 @@ var TypeScript; } return this.childDeclNamespaceCache; - } else if (TypeScript.hasFlag(declKind, 58728539 /* SomeType */)) { + } else if (TypeScript.hasFlag(declKind, 58728795 /* SomeType */)) { if (!this.childDeclTypeCache) { this.childDeclTypeCache = TypeScript.createIntrinsicsObject(); } @@ -34995,7 +35129,7 @@ var TypeScript; PullDecl.prototype.searchChildDecls = function (declName, searchKind) { var cacheVal = null; - if (searchKind & 58728539 /* SomeType */) { + if (searchKind & 58728795 /* SomeType */) { cacheVal = this.childDeclTypeCache ? this.childDeclTypeCache[declName] : null; } else if (searchKind & 164 /* SomeContainer */) { cacheVal = this.childDeclNamespaceCache ? this.childDeclNamespaceCache[declName] : null; @@ -35006,7 +35140,7 @@ var TypeScript; if (cacheVal) { return cacheVal; } else { - if (searchKind & 58728539 /* SomeType */) { + if (searchKind & 58728795 /* SomeType */) { cacheVal = this.childDeclTypeParameterCache ? this.childDeclTypeParameterCache[declName] : null; if (cacheVal) { @@ -35019,11 +35153,11 @@ var TypeScript; }; PullDecl.prototype.getChildDecls = function () { - return this.childDecls ? this.childDecls : sentinelEmptyPullDeclArray; + return this.childDecls || sentinelEmptyPullDeclArray; }; PullDecl.prototype.getTypeParameters = function () { - return this.typeParameters ? this.typeParameters : sentinelEmptyPullDeclArray; + return this.typeParameters || sentinelEmptyPullDeclArray; }; PullDecl.prototype.addVariableDeclToGroup = function (decl) { @@ -35056,7 +35190,7 @@ var TypeScript; } } - return declGroups ? declGroups : sentinelEmptyPullDeclArray; + return declGroups || sentinelEmptyPullDeclArray; }; PullDecl.prototype.hasBeenBound = function () { @@ -35068,8 +35202,11 @@ var TypeScript; }; PullDecl.prototype.ast = function () { - var semanticInfoChain = this.semanticInfoChain(); - return semanticInfoChain ? semanticInfoChain.getASTForDecl(this) : null; + return this.semanticInfoChain.getASTForDecl(this); + }; + + PullDecl.prototype.isRootDecl = function () { + throw TypeScript.Errors.abstract(); }; return PullDecl; })(); @@ -35077,9 +35214,9 @@ var TypeScript; var RootPullDecl = (function (_super) { __extends(RootPullDecl, _super); - function RootPullDecl(name, fileName, kind, declFlags, span, semanticInfoChain, isExternalModule) { - _super.call(this, name, name, kind, declFlags, span); - this._semanticInfoChain = semanticInfoChain; + function RootPullDecl(name, fileName, kind, declFlags, semanticInfoChain, isExternalModule) { + _super.call(this, name, name, kind, declFlags, semanticInfoChain); + this.semanticInfoChain = semanticInfoChain; this._isExternalModule = isExternalModule; this._fileName = fileName; } @@ -35095,10 +35232,6 @@ var TypeScript; return null; }; - RootPullDecl.prototype.semanticInfoChain = function () { - return this._semanticInfoChain; - }; - RootPullDecl.prototype.isExternalModule = function () { return this._isExternalModule; }; @@ -35106,15 +35239,18 @@ var TypeScript; RootPullDecl.prototype.getEnclosingDecl = function () { return this; }; + RootPullDecl.prototype.isRootDecl = function () { + return true; + }; return RootPullDecl; })(PullDecl); TypeScript.RootPullDecl = RootPullDecl; var NormalPullDecl = (function (_super) { __extends(NormalPullDecl, _super); - function NormalPullDecl(declName, displayName, kind, declFlags, parentDecl, span, addToParent) { + function NormalPullDecl(declName, displayName, kind, declFlags, parentDecl, addToParent) { if (typeof addToParent === "undefined") { addToParent = true; } - _super.call(this, declName, displayName, kind, declFlags, span); + _super.call(this, declName, displayName, kind, declFlags, parentDecl ? parentDecl.semanticInfoChain : null); this.parentDecl = null; this.parentPath = null; @@ -35122,9 +35258,20 @@ var TypeScript; if (addToParent) { parentDecl.addChildDecl(this); } + + if (this.parentDecl) { + if (this.parentDecl.isRootDecl()) { + this._rootDecl = this.parentDecl; + } else { + this._rootDecl = this.parentDecl._rootDecl; + } + } else { + TypeScript.Debug.assert(this.isSynthesized()); + this._rootDecl = null; + } } NormalPullDecl.prototype.fileName = function () { - return this.parentDecl ? this.parentDecl.fileName() : ""; + return this._rootDecl.fileName(); }; NormalPullDecl.prototype.getParentDecl = function () { @@ -35137,7 +35284,7 @@ var TypeScript; var parentDecl = this.parentDecl; while (parentDecl) { - if (parentDecl && path[path.length - 1] != parentDecl && !(parentDecl.kind & 256 /* ObjectLiteral */)) { + if (parentDecl && path[path.length - 1] !== parentDecl && !(parentDecl.kind & (256 /* ObjectLiteral */ | 8388608 /* ObjectType */))) { path.unshift(parentDecl); } @@ -35150,11 +35297,6 @@ var TypeScript; return this.parentPath; }; - NormalPullDecl.prototype.semanticInfoChain = function () { - var parent = this.getParentDecl(); - return parent ? parent.semanticInfoChain() : null; - }; - NormalPullDecl.prototype.isExternalModule = function () { return false; }; @@ -35162,14 +35304,18 @@ var TypeScript; NormalPullDecl.prototype.getEnclosingDecl = function () { return this.parentDecl && this.parentDecl._getEnclosingDeclFromParentDecl(); }; + + NormalPullDecl.prototype.isRootDecl = function () { + return false; + }; return NormalPullDecl; })(PullDecl); TypeScript.NormalPullDecl = NormalPullDecl; var PullEnumElementDecl = (function (_super) { __extends(PullEnumElementDecl, _super); - function PullEnumElementDecl(declName, displayName, parentDecl, span) { - _super.call(this, declName, displayName, 67108864 /* EnumMember */, 4 /* Public */, parentDecl, span); + function PullEnumElementDecl(declName, displayName, parentDecl) { + _super.call(this, declName, displayName, 67108864 /* EnumMember */, 4 /* Public */, parentDecl); this.constantValue = null; } return PullEnumElementDecl; @@ -35178,9 +35324,9 @@ var TypeScript; var PullFunctionExpressionDecl = (function (_super) { __extends(PullFunctionExpressionDecl, _super); - function PullFunctionExpressionDecl(expressionName, declFlags, parentDecl, span, displayName) { + function PullFunctionExpressionDecl(expressionName, declFlags, parentDecl, displayName) { if (typeof displayName === "undefined") { displayName = ""; } - _super.call(this, "", displayName, 131072 /* FunctionExpression */, declFlags, parentDecl, span); + _super.call(this, "", displayName, 131072 /* FunctionExpression */, declFlags, parentDecl); this.functionExpressionName = expressionName; } PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { @@ -35192,17 +35338,17 @@ var TypeScript; var PullSynthesizedDecl = (function (_super) { __extends(PullSynthesizedDecl, _super); - function PullSynthesizedDecl(declName, displayName, kind, declFlags, parentDecl, span, semanticInfoChain) { - _super.call(this, declName, displayName, kind, declFlags, parentDecl, span, false); - this._semanticInfoChain = semanticInfoChain; + function PullSynthesizedDecl(declName, displayName, kind, declFlags, parentDecl, semanticInfoChain) { + _super.call(this, declName, displayName, kind, declFlags, parentDecl, false); + this.semanticInfoChain = semanticInfoChain; } - PullSynthesizedDecl.prototype.semanticInfoChain = function () { - return this._semanticInfoChain; - }; - PullSynthesizedDecl.prototype.isSynthesized = function () { return true; }; + + PullSynthesizedDecl.prototype.fileName = function () { + return this._rootDecl ? this._rootDecl.fileName() : ""; + }; return PullSynthesizedDecl; })(NormalPullDecl); TypeScript.PullSynthesizedDecl = PullSynthesizedDecl; @@ -35228,12 +35374,11 @@ var TypeScript; var TypeScript; (function (TypeScript) { TypeScript.pullSymbolID = 0; - TypeScript.globalTyvarID = 0; TypeScript.sentinelEmptyArray = []; var PullSymbol = (function () { function PullSymbol(name, declKind) { - this.pullSymbolID = TypeScript.pullSymbolID++; + this.pullSymbolID = ++TypeScript.pullSymbolID; this._container = null; this.type = null; this._declarations = null; @@ -35254,7 +35399,7 @@ var TypeScript; }; PullSymbol.prototype.isType = function () { - return (this.kind & 58728539 /* SomeType */) != 0; + return (this.kind & 58728795 /* SomeType */) !== 0; }; PullSymbol.prototype.isTypeReference = function () { @@ -35262,7 +35407,7 @@ var TypeScript; }; PullSymbol.prototype.isSignature = function () { - return (this.kind & 7340032 /* SomeSignature */) != 0; + return (this.kind & 7340032 /* SomeSignature */) !== 0; }; PullSymbol.prototype.isArrayNamedTypeReference = function () { @@ -35323,7 +35468,7 @@ var TypeScript; return aliasSymbols; } - if (!skipScopeSymbolAliasesLookIn && this.isExternalModuleReferenceAlias(symbol) && (!symbol.assignedContainer().hasExportAssignment() || (symbol.assignedContainer().getExportAssignedContainerSymbol() && symbol.assignedContainer().getExportAssignedContainerSymbol().kind == 32 /* DynamicModule */))) { + if (!skipScopeSymbolAliasesLookIn && this.isExternalModuleReferenceAlias(symbol) && (!symbol.assignedContainer().hasExportAssignment() || (symbol.assignedContainer().getExportAssignedContainerSymbol() && symbol.assignedContainer().getExportAssignedContainerSymbol().kind === 32 /* DynamicModule */))) { scopeSymbolAliasesToLookIn.push(symbol); } } @@ -35366,11 +35511,11 @@ var TypeScript; return false; } - if (aliasSymbol.assignedType() && aliasSymbol.assignedType() != aliasSymbol.assignedContainer()) { + if (aliasSymbol.assignedType() && aliasSymbol.assignedType() !== aliasSymbol.assignedContainer()) { return false; } - if (aliasSymbol.assignedContainer() && aliasSymbol.assignedContainer().kind != 32 /* DynamicModule */) { + if (aliasSymbol.assignedContainer() && aliasSymbol.assignedContainer().kind !== 32 /* DynamicModule */) { return false; } @@ -35382,12 +35527,12 @@ var TypeScript; PullSymbol.prototype.getExportedInternalAliasSymbol = function (scopeSymbol) { if (scopeSymbol) { - if (this.kind != 128 /* TypeAlias */) { + if (this.kind !== 128 /* TypeAlias */) { var scopePath = scopeSymbol.pathToRoot(); for (var i = 0; i < scopePath.length; i++) { var internalAliases = this.findAliasedType(scopeSymbol, true, true); if (internalAliases) { - TypeScript.Debug.assert(internalAliases.length == 1); + TypeScript.Debug.assert(internalAliases.length === 1); return internalAliases[0]; } } @@ -35408,11 +35553,14 @@ var TypeScript; var externalAliases = this.getExternalAliasedSymbols(scopeSymbol); if (externalAliases && this.isExternalModuleReferenceAlias(externalAliases[externalAliases.length - 1])) { - var aliasFullName = ""; + var aliasFullName = aliasNameGetter(externalAliases[0]); + if (!aliasFullName) { + return null; + } for (var i = 1, symbolsLen = externalAliases.length; i < symbolsLen; i++) { aliasFullName = aliasFullName + "." + aliasPartsNameGetter(externalAliases[i]); } - return aliasNameGetter(externalAliases[0]) + aliasFullName; + return aliasFullName; } return null; @@ -35420,7 +35568,7 @@ var TypeScript; PullSymbol.prototype._getResolver = function () { TypeScript.Debug.assert(this._declarations && this._declarations.length > 0); - return this._declarations[0].semanticInfoChain().getResolver(); + return this._declarations[0].semanticInfoChain.getResolver(); }; PullSymbol.prototype._resolveDeclaredSymbol = function () { @@ -35433,11 +35581,7 @@ var TypeScript; }, function (symbol) { return symbol.getName(); }); - if (aliasName != null) { - return aliasName; - } - - return this.name; + return aliasName || this.name; }; PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { @@ -35446,7 +35590,7 @@ var TypeScript; }, function (symbol) { return symbol.getDisplayName(); }, skipInternalAliasName); - if (aliasDisplayName != null) { + if (aliasDisplayName) { return aliasDisplayName; } @@ -35472,10 +35616,14 @@ var TypeScript; PullSymbol.prototype.setIsSynthesized = function (value) { if (typeof value === "undefined") { value = true; } + TypeScript.Debug.assert(this.rootSymbol == null); this.isSynthesized = value; }; PullSymbol.prototype.getIsSynthesized = function () { + if (this.rootSymbol) { + return this.rootSymbol.getIsSynthesized(); + } return this.isSynthesized; }; @@ -35585,7 +35733,7 @@ var TypeScript; } path[path.length] = node; var nodeKind = node.kind; - if (nodeKind == 2048 /* Parameter */) { + if (nodeKind === 2048 /* Parameter */) { break; } else { node = node.getContainer(); @@ -35594,54 +35742,61 @@ var TypeScript; return path; }; - PullSymbol.prototype.findCommonAncestorPath = function (b) { - var aPath = this.pathToRoot(); - if (aPath.length === 1) { - return aPath; - } + PullSymbol.unqualifiedNameReferencesDifferentSymbolInScope = function (symbol, scopePath, endScopePathIndex) { + var declPath = scopePath[0].getDeclarations()[0].getParentPath(); + for (var i = 0, declIndex = declPath.length - 1; i <= endScopePathIndex; i++, declIndex--) { + if (symbol.isContainer() && scopePath[i].isContainer()) { + var scopeType = scopePath[i]; - var bPath; - if (b) { - bPath = b.pathToRoot(); - } else { - return aPath; - } + var memberSymbol = scopeType.findContainedNonMemberContainer(symbol.name, 164 /* SomeContainer */); + if (memberSymbol && memberSymbol != symbol && memberSymbol.getDeclarations()[0].getParentDecl() == declPath[declIndex]) { + return true; + } - var commonNodeIndex = -1; - for (var i = 0, aLen = aPath.length; i < aLen; i++) { - var aNode = aPath[i]; - for (var j = 0, bLen = bPath.length; j < bLen; j++) { - var bNode = bPath[j]; - if (aNode === bNode) { - var aDecl = null; - if (i > 0) { - var decls = aPath[i - 1].getDeclarations(); - if (decls.length) { - aDecl = decls[0].getParentDecl(); - } - } - var bDecl = null; - if (j > 0) { - var decls = bPath[j - 1].getDeclarations(); - if (decls.length) { - bDecl = decls[0].getParentDecl(); - } - } - if (!aDecl || !bDecl || aDecl == bDecl) { - commonNodeIndex = i; - break; - } + var memberSymbol = scopeType.findNestedContainer(symbol.name, 164 /* SomeContainer */); + if (memberSymbol && memberSymbol != symbol) { + return true; } } - if (commonNodeIndex >= 0) { - break; + } + + return false; + }; + + PullSymbol.prototype.findQualifyingSymbolPathInScopeSymbol = function (scopeSymbol) { + var thisPath = this.pathToRoot(); + if (thisPath.length === 1) { + return thisPath; + } + + var scopeSymbolPath; + if (scopeSymbol) { + scopeSymbolPath = scopeSymbol.pathToRoot(); + } else { + return thisPath; + } + + var thisCommonAncestorIndex = TypeScript.ArrayUtilities.indexOf(thisPath, function (thisNode) { + return TypeScript.ArrayUtilities.contains(scopeSymbolPath, thisNode); + }); + if (thisCommonAncestorIndex > 0) { + var thisCommonAncestor = thisPath[thisCommonAncestorIndex]; + var scopeCommonAncestorIndex = TypeScript.ArrayUtilities.indexOf(scopeSymbolPath, function (scopeNode) { + return scopeNode === thisCommonAncestor; + }); + TypeScript.Debug.assert(thisPath.length - thisCommonAncestorIndex === scopeSymbolPath.length - scopeCommonAncestorIndex); + + for (; thisCommonAncestorIndex < thisPath.length; thisCommonAncestorIndex++, scopeCommonAncestorIndex++) { + if (!PullSymbol.unqualifiedNameReferencesDifferentSymbolInScope(thisPath[thisCommonAncestorIndex - 1], scopeSymbolPath, scopeCommonAncestorIndex)) { + break; + } } } - if (commonNodeIndex >= 0) { - return aPath.slice(0, commonNodeIndex); + if (thisCommonAncestorIndex >= 0 && thisCommonAncestorIndex < thisPath.length) { + return thisPath.slice(0, thisCommonAncestorIndex); } else { - return aPath; + return thisPath; } }; @@ -35655,6 +35810,7 @@ var TypeScript; }; PullSymbol.prototype.fullName = function (scopeSymbol) { + var _this = this; var path = this.pathToRoot(); var fullName = ""; @@ -35663,23 +35819,23 @@ var TypeScript; }, function (symbol) { return symbol.getNamePartForFullName(); }); - if (aliasFullName != null) { + if (aliasFullName) { return aliasFullName; } for (var i = 1; i < path.length; i++) { var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.fullName(scopeSymbol); + return symbol === _this ? null : symbol.fullName(scopeSymbol); }, function (symbol) { return symbol.getNamePartForFullName(); }); - if (aliasFullName != null) { + if (aliasFullName) { fullName = aliasFullName + "." + fullName; break; } var scopedName = path[i].getNamePartForFullName(); - if (path[i].kind == 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { + if (path[i].kind === 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { break; } @@ -35695,7 +35851,7 @@ var TypeScript; }; PullSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { - var path = this.findCommonAncestorPath(scopeSymbol); + var path = this.findQualifyingSymbolPathInScopeSymbol(scopeSymbol); var fullName = ""; var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { @@ -35703,7 +35859,7 @@ var TypeScript; }, function (symbol) { return symbol.getNamePartForFullName(); }, skipInternalAliasName); - if (aliasFullName != null) { + if (aliasFullName) { return aliasFullName; } @@ -35715,7 +35871,7 @@ var TypeScript; }, function (symbol) { return symbol.getNamePartForFullName(); }, skipInternalAliasName); - if (aliasFullName != null) { + if (aliasFullName) { fullName = aliasFullName + "." + fullName; break; } @@ -35762,9 +35918,9 @@ var TypeScript; PullSymbol.prototype.getTypeNameForFunctionSignature = function (prefix, scopeSymbol, getPrettyTypeName) { var type = this.type; - if (type && !type.isNamedTypeSymbol() && this.kind != 4096 /* Property */ && this.kind != 512 /* Variable */ && this.kind != 2048 /* Parameter */) { + if (type && !type.isNamedTypeSymbol() && this.kind !== 4096 /* Property */ && this.kind !== 512 /* Variable */ && this.kind !== 2048 /* Parameter */) { var signatures = type.getCallSignatures(); - if (signatures.length == 1 || (getPrettyTypeName && signatures.length)) { + if (signatures.length === 1 || (getPrettyTypeName && signatures.length)) { var typeName = new TypeScript.MemberNameArray(); var signatureName = PullSignatureSymbol.getSignaturesTypeNameEx(signatures, prefix, false, false, scopeSymbol, getPrettyTypeName); typeName.addAll(signatureName); @@ -35881,7 +36037,7 @@ var TypeScript; var parentDecl = decls[0].getParentDecl(); if (parentDecl) { var parentSymbol = parentDecl.getSymbol(); - if (!parentSymbol || parentDecl.kind == 1 /* Script */) { + if (!parentSymbol || parentDecl.kind === 1 /* Script */) { return true; } @@ -35892,14 +36048,14 @@ var TypeScript; return true; } - if (container.kind == 32 /* DynamicModule */ || (container.getAssociatedContainerType() && container.getAssociatedContainerType().kind == 32 /* DynamicModule */)) { - var containerSymbol = container.kind == 32 /* DynamicModule */ ? container : container.getAssociatedContainerType(); + if (container.kind === 32 /* DynamicModule */ || (container.getAssociatedContainerType() && container.getAssociatedContainerType().kind === 32 /* DynamicModule */)) { + var containerSymbol = container.kind === 32 /* DynamicModule */ ? container : container.getAssociatedContainerType(); if (PullContainerSymbol.usedAsSymbol(containerSymbol, this)) { return true; } } - if (!this.anyDeclHasFlag(1 /* Exported */) && kind != 4096 /* Property */ && kind != 65536 /* Method */) { + if (!this.anyDeclHasFlag(1 /* Exported */) && kind !== 4096 /* Property */ && kind !== 65536 /* Method */) { return false; } @@ -35910,13 +36066,13 @@ var TypeScript; var ast = decl.ast(); if (ast) { - var enclosingModuleDeclaration = TypeScript.getEnclosingModuleDeclaration(ast); - if (TypeScript.isLastNameOfModule(enclosingModuleDeclaration, ast)) { - return TypeScript.docComments(enclosingModuleDeclaration); + var enclosingModuleDeclaration = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(ast); + if (TypeScript.ASTHelpers.isLastNameOfModule(enclosingModuleDeclaration, ast)) { + return TypeScript.ASTHelpers.docComments(enclosingModuleDeclaration); } - if (ast.kind() != 130 /* ModuleDeclaration */ || decl.kind != 512 /* Variable */) { - return TypeScript.docComments(ast); + if (ast.kind() !== 130 /* ModuleDeclaration */ || decl.kind !== 512 /* Variable */) { + return TypeScript.ASTHelpers.docComments(ast); } } @@ -35929,10 +36085,10 @@ var TypeScript; return docComments; } - var isParameter = symbol.kind == 2048 /* Parameter */; + var isParameter = symbol.kind === 2048 /* Parameter */; var decls = symbol.getDeclarations(); for (var i = 0; i < decls.length; i++) { - if (isParameter && decls[i].kind == 4096 /* Property */) { + if (isParameter && decls[i].kind === 4096 /* Property */) { continue; } docComments = docComments.concat(this.getDocCommentsOfDecl(decls[i])); @@ -35968,14 +36124,14 @@ var TypeScript; PullSymbol.prototype.docComments = function (useConstructorAsClass) { var decls = this.getDeclarations(); - if (useConstructorAsClass && decls.length && decls[0].kind == 32768 /* ConstructorMethod */) { + if (useConstructorAsClass && decls.length && decls[0].kind === 32768 /* ConstructorMethod */) { var classDecl = decls[0].getParentDecl(); return this.getDocCommentText(this.getDocCommentsOfDecl(classDecl)); } if (this._docComments === null) { var docComments = ""; - if (!useConstructorAsClass && this.kind == 2097152 /* ConstructSignature */ && decls.length && decls[0].kind == 8 /* Class */) { + if (!useConstructorAsClass && this.kind === 2097152 /* ConstructSignature */ && decls.length && decls[0].kind === 8 /* Class */) { var classSymbol = this.returnType; var extendedTypes = classSymbol.getExtendedTypes(); if (extendedTypes.length) { @@ -35983,7 +36139,7 @@ var TypeScript; } else { docComments = ""; } - } else if (this.kind == 2048 /* Parameter */) { + } else if (this.kind === 2048 /* Parameter */) { var parameterComments = []; var funcContainer = this.getEnclosingSignature(); @@ -36000,7 +36156,7 @@ var TypeScript; docComments = parameterComments.join("\n"); } else { var getSymbolComments = true; - if (this.kind == 16777216 /* FunctionType */) { + if (this.kind === 16777216 /* FunctionType */) { var functionSymbol = this.getFunctionSymbol(); if (functionSymbol) { @@ -36016,10 +36172,10 @@ var TypeScript; } if (getSymbolComments) { docComments = this.getDocCommentText(this.getDocCommentArray(this)); - if (docComments == "") { - if (this.kind == 1048576 /* CallSignature */) { + if (docComments === "") { + if (this.kind === 1048576 /* CallSignature */) { var callTypeSymbol = this.functionType; - if (callTypeSymbol && callTypeSymbol.getCallSignatures().length == 1) { + if (callTypeSymbol && callTypeSymbol.getCallSignatures().length === 1) { docComments = callTypeSymbol.docComments(); } } @@ -36230,34 +36386,41 @@ var TypeScript; })(); TypeScript.PullSymbol = PullSymbol; + + var PullSignatureSymbol = (function (_super) { __extends(PullSignatureSymbol, _super); - function PullSignatureSymbol(kind) { + function PullSignatureSymbol(kind, _isDefinition) { + if (typeof _isDefinition === "undefined") { _isDefinition = false; } _super.call(this, "", kind); + this._isDefinition = _isDefinition; this._memberTypeParameterNameCache = null; this._stringConstantOverload = undefined; this.parameters = TypeScript.sentinelEmptyArray; - this.typeParameters = null; + this._typeParameters = null; this.returnType = null; this.functionType = null; this.hasOptionalParam = false; this.nonOptionalParamCount = 0; this.hasVarArgs = false; - this.hasAGenericParameter = false; + this._allowedToReferenceTypeParameters = null; + this._instantiationCache = null; this.hasBeenChecked = false; this.inWrapCheck = false; + this.inWrapInfiniteExpandingReferenceCheck = false; } PullSignatureSymbol.prototype.isDefinition = function () { - return false; + return this._isDefinition; }; PullSignatureSymbol.prototype.isGeneric = function () { - return this.hasAGenericParameter || (this.typeParameters && this.typeParameters.length != 0); + var typeParameters = this.getTypeParameters(); + return !!typeParameters && typeParameters.length !== 0; }; PullSignatureSymbol.prototype.addParameter = function (parameter, isOptional) { if (typeof isOptional === "undefined") { isOptional = false; } - if (this.parameters == TypeScript.sentinelEmptyArray) { + if (this.parameters === TypeScript.sentinelEmptyArray) { this.parameters = []; } @@ -36274,25 +36437,32 @@ var TypeScript; }; PullSignatureSymbol.prototype.addTypeParameter = function (typeParameter) { - if (!this.typeParameters) { - this.typeParameters = []; + if (!this._typeParameters) { + this._typeParameters = []; } if (!this._memberTypeParameterNameCache) { this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); } - this.typeParameters[this.typeParameters.length] = typeParameter; + this._typeParameters[this._typeParameters.length] = typeParameter; this._memberTypeParameterNameCache[typeParameter.getName()] = typeParameter; }; + PullSignatureSymbol.prototype.addTypeParametersFromReturnType = function () { + var typeParameters = this.returnType.getTypeParameters(); + for (var i = 0; i < typeParameters.length; i++) { + this.addTypeParameter(typeParameters[i]); + } + }; + PullSignatureSymbol.prototype.getTypeParameters = function () { - if (!this.typeParameters) { - this.typeParameters = []; + if (!this._typeParameters) { + this._typeParameters = []; } - return this.typeParameters; + return this._typeParameters; }; PullSignatureSymbol.prototype.findTypeParameter = function (name) { @@ -36301,10 +36471,8 @@ var TypeScript; if (!this._memberTypeParameterNameCache) { this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); - if (this.typeParameters) { - for (var i = 0; i < this.typeParameters.length; i++) { - this._memberTypeParameterNameCache[this.typeParameters[i].getName()] = this.typeParameters[i]; - } + for (var i = 0; i < this.getTypeParameters().length; i++) { + this._memberTypeParameterNameCache[this._typeParameters[i].getName()] = this._typeParameters[i]; } } @@ -36313,6 +36481,38 @@ var TypeScript; return memberSymbol; }; + PullSignatureSymbol.prototype.getTypeParameterArgumentMap = function () { + return null; + }; + + PullSignatureSymbol.prototype.getAllowedToReferenceTypeParameters = function () { + TypeScript.Debug.assert(this.getRootSymbol() == this); + if (!this._allowedToReferenceTypeParameters) { + this._allowedToReferenceTypeParameters = TypeScript.PullInstantiationHelpers.getAllowedToReferenceTypeParametersFromDecl(this.getDeclarations()[0]); + } + + return this._allowedToReferenceTypeParameters; + }; + + PullSignatureSymbol.prototype.addSpecialization = function (specializedVersionOfThisSignature, typeArgumentMap) { + TypeScript.Debug.assert(this.getRootSymbol() == this); + if (!this._instantiationCache) { + this._instantiationCache = TypeScript.createIntrinsicsObject(); + } + + this._instantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)] = specializedVersionOfThisSignature; + }; + + PullSignatureSymbol.prototype.getSpecialization = function (typeArgumentMap) { + TypeScript.Debug.assert(this.getRootSymbol() == this); + if (!this._instantiationCache) { + return null; + } + + var result = this._instantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)]; + return result || null; + }; + PullSignatureSymbol.prototype.isStringConstantOverloadSignature = function () { if (this._stringConstantOverload === undefined) { var params = this.parameters; @@ -36328,6 +36528,20 @@ var TypeScript; return this._stringConstantOverload; }; + PullSignatureSymbol.prototype.getParameterTypeAtIndex = function (iParam) { + if (iParam < this.parameters.length - 1 || (iParam < this.parameters.length && !this.hasVarArgs)) { + return this.parameters[iParam].type; + } else if (this.hasVarArgs) { + var paramType = this.parameters[this.parameters.length - 1].type; + if (paramType.isArrayNamedTypeReference()) { + paramType = paramType.getElementType(); + } + return paramType; + } + + return null; + }; + PullSignatureSymbol.getSignatureTypeMemberName = function (candidateSignature, signatures, scopeSymbol) { var allMemberNames = new TypeScript.MemberNameArray(); var signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(signatures, "", false, false, scopeSymbol, true, candidateSignature); @@ -36455,75 +36669,110 @@ var TypeScript; return builder; }; + PullSignatureSymbol.prototype.forAllParameterTypes = function (length, predicate) { + if (this.parameters.length < length && !this.hasVarArgs) { + length = this.parameters.length; + } + + for (var i = 0; i < length; i++) { + var paramType = this.getParameterTypeAtIndex(i); + if (!predicate(paramType, i)) { + return false; + } + } + + return true; + }; + + PullSignatureSymbol.prototype.forAllCorrespondingParameterTypesInThisAndOtherSignature = function (otherSignature, predicate) { + var length; + if (this.hasVarArgs) { + length = otherSignature.hasVarArgs ? Math.max(this.parameters.length, otherSignature.parameters.length) : otherSignature.parameters.length; + } else { + length = otherSignature.hasVarArgs ? this.parameters.length : Math.min(this.parameters.length, otherSignature.parameters.length); + } + + for (var i = 0; i < length; i++) { + var thisParamType = this.getParameterTypeAtIndex(i); + var otherParamType = otherSignature.getParameterTypeAtIndex(i); + if (!predicate(thisParamType, otherParamType, i)) { + return false; + } + } + + return true; + }; + PullSignatureSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap) { + return this.getWrappingTypeParameterID(typeParameterArgumentMap) !== 0; + }; + + PullSignatureSymbol.prototype.getWrappingTypeParameterID = function (typeParameterArgumentMap) { var signature = this; if (signature.inWrapCheck) { - return false; + return 0; } + this._wrapsTypeParameterCache = this._wrapsTypeParameterCache || new TypeScript.WrapsTypeParameterCache(); + + var wrappingTypeParameterID = this._wrapsTypeParameterCache.getWrapsTypeParameter(typeParameterArgumentMap); + if (wrappingTypeParameterID === undefined) { + wrappingTypeParameterID = this.getWrappingTypeParameterIDWorker(typeParameterArgumentMap); + this._wrapsTypeParameterCache.setWrapsTypeParameter(typeParameterArgumentMap, wrappingTypeParameterID); + } + + return wrappingTypeParameterID; + }; + + PullSignatureSymbol.prototype.getWrappingTypeParameterIDWorker = function (typeParameterArgumentMap) { + var signature = this; signature.inWrapCheck = true; + TypeScript.PullHelpers.resolveDeclaredSymbolToUseType(signature); + var wrappingTypeParameterID = signature.returnType ? signature.returnType.getWrappingTypeParameterID(typeParameterArgumentMap) : 0; - var wrapsSomeTypeParameter = false; - - if (signature.returnType && signature.returnType.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - wrapsSomeTypeParameter = true; - } - - if (!wrapsSomeTypeParameter) { - var parameters = signature.parameters; - - for (var i = 0; i < parameters.length; i++) { - if (!parameters[i].type) { - parameters[i]._resolveDeclaredSymbol(); - } - - if (parameters[i].type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - wrapsSomeTypeParameter = true; - break; - } - } + var parameters = signature.parameters; + for (var i = 0; !wrappingTypeParameterID && i < parameters.length; i++) { + TypeScript.PullHelpers.resolveDeclaredSymbolToUseType(parameters[i]); + wrappingTypeParameterID = parameters[i].type.getWrappingTypeParameterID(typeParameterArgumentMap); } signature.inWrapCheck = false; - return wrapsSomeTypeParameter; + return wrappingTypeParameterID; }; - PullSignatureSymbol.prototype.wrapsSomeNestedTypeIntoInfiniteExpansion = function (typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap) { - if (this.inWrapCheck) { - return isCheckingTypeArgumentList; + PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference = function (enclosingType, knownWrapMap) { + var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); + if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { + return wrapsIntoInfinitelyExpandingTypeReference; } - if (knownWrapMap.valueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID) != undefined) { - return knownWrapMap.valueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID); + if (this.inWrapInfiniteExpandingReferenceCheck) { + return false; } - knownWrapMap.setValueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID, isCheckingTypeArgumentList); + this.inWrapInfiniteExpandingReferenceCheck = true; + wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); + knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); + this.inWrapInfiniteExpandingReferenceCheck = false; - this.inWrapCheck = true; + return wrapsIntoInfinitelyExpandingTypeReference; + }; - var wrapsSomeWrappedTypeParameter = false; - - if (this.returnType && this.returnType._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap)) { - wrapsSomeWrappedTypeParameter = true; + PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker = function (enclosingType, knownWrapMap) { + if (this.returnType && this.returnType._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; } - if (!wrapsSomeWrappedTypeParameter) { - var parameters = this.parameters; + var parameters = this.parameters; - for (var i = 0; i < parameters.length; i++) { - if (parameters[i].type && parameters[i].type._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap)) { - wrapsSomeWrappedTypeParameter = true; - break; - } + for (var i = 0; i < parameters.length; i++) { + if (parameters[i].type && parameters[i].type._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; } } - knownWrapMap.setValueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID, wrapsSomeWrappedTypeParameter); - - this.inWrapCheck = false; - - return wrapsSomeWrappedTypeParameter; + return false; }; return PullSignatureSymbol; })(PullSymbol); @@ -36537,6 +36786,7 @@ var TypeScript; this._enclosedMemberTypes = null; this._enclosedMemberContainers = null; this._typeParameters = null; + this._allowedToReferenceTypeParameters = null; this._specializedVersionsOfThisType = null; this._arrayVersionOfThisType = null; this._implementedTypes = null; @@ -36548,6 +36798,7 @@ var TypeScript; this._constructSignatures = null; this._indexSignatures = null; this._allIndexSignatures = null; + this._allIndexSignaturesOfAugmentedType = null; this._memberNameCache = null; this._enclosedTypeNameCache = null; this._enclosedContainerCache = null; @@ -36568,7 +36819,9 @@ var TypeScript; this._inMemberTypeNameEx = false; this.inSymbolPrivacyCheck = false; this.inWrapCheck = false; + this.inWrapInfiniteExpandingReferenceCheck = false; this.typeReference = null; + this._widenedType = null; this._isArrayNamedTypeReference = undefined; this.type = this; } @@ -36583,7 +36836,6 @@ var TypeScript; PullTypeSymbol.prototype.computeIsArrayNamedTypeReference = function () { var typeArgs = this.getTypeArguments(); if (typeArgs && this.getTypeArguments().length === 1 && this.name === "Array") { - var container = this.getContainer(); var declaration = this.getDeclarations()[0]; if (declaration && declaration.getParentDecl() && declaration.getParentDecl().getParentDecl() === null) { @@ -36598,13 +36850,13 @@ var TypeScript; return true; }; PullTypeSymbol.prototype.isClass = function () { - return this.kind == 8 /* Class */ || (this._constructorMethod != null); + return this.kind === 8 /* Class */ || (this._constructorMethod !== null); }; PullTypeSymbol.prototype.isFunction = function () { - return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) != 0; + return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) !== 0; }; PullTypeSymbol.prototype.isConstructor = function () { - return this.kind == 33554432 /* ConstructorType */; + return this.kind === 33554432 /* ConstructorType */; }; PullTypeSymbol.prototype.isTypeParameter = function () { return false; @@ -36616,7 +36868,7 @@ var TypeScript; return false; }; PullTypeSymbol.prototype.isEnum = function () { - return this.kind == 64 /* Enum */; + return this.kind === 64 /* Enum */; }; PullTypeSymbol.prototype.getTypeParameterArgumentMap = function () { @@ -36624,7 +36876,11 @@ var TypeScript; }; PullTypeSymbol.prototype.isObject = function () { - return TypeScript.hasFlag(this.kind, 8 /* Class */ | 33554432 /* ConstructorType */ | 64 /* Enum */ | 16777216 /* FunctionType */ | 16 /* Interface */ | 8388608 /* ObjectType */); + return TypeScript.hasFlag(this.kind, 8 /* Class */ | 33554432 /* ConstructorType */ | 64 /* Enum */ | 16777216 /* FunctionType */ | 16 /* Interface */ | 8388608 /* ObjectType */ | 256 /* ObjectLiteral */); + }; + + PullTypeSymbol.prototype.isFunctionType = function () { + return this.getCallSignatures().length > 0 || this.getConstructSignatures().length > 0; }; PullTypeSymbol.prototype.getKnownBaseTypeCount = function () { @@ -36645,7 +36901,7 @@ var TypeScript; }; PullTypeSymbol.prototype.hasMembers = function () { - if (this._members != TypeScript.sentinelEmptyArray) { + if (this._members !== TypeScript.sentinelEmptyArray) { return true; } @@ -36720,8 +36976,8 @@ var TypeScript; var nonMemberSymbol = this._containedNonMemberTypeNameCache[typeName]; - if (nonMemberSymbol && kind != 0 /* None */) { - nonMemberSymbol = ((nonMemberSymbol.kind & kind) != 0) ? nonMemberSymbol : null; + if (nonMemberSymbol && kind !== 0 /* None */) { + nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; } return nonMemberSymbol; @@ -36735,8 +36991,8 @@ var TypeScript; var nonMemberSymbol = this._containedNonMemberContainerCache[containerName]; - if (nonMemberSymbol && kind != 0 /* None */) { - nonMemberSymbol = ((nonMemberSymbol.kind & kind) != 0) ? nonMemberSymbol : null; + if (nonMemberSymbol && kind !== 0 /* None */) { + nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; } return nonMemberSymbol; @@ -36862,16 +37118,6 @@ var TypeScript; this._typeParameterNameCache[typeParameter.getName()] = typeParameter; }; - PullTypeSymbol.prototype.addConstructorTypeParameter = function (typeParameter) { - this.addTypeParameter(typeParameter); - - var constructSignatures = this.getConstructSignatures(); - - for (var i = 0; i < constructSignatures.length; i++) { - constructSignatures[i].addTypeParameter(typeParameter); - } - }; - PullTypeSymbol.prototype.getMembers = function () { return this._members; }; @@ -36901,31 +37147,52 @@ var TypeScript; return this._typeParameters; }; + PullTypeSymbol.prototype.getAllowedToReferenceTypeParameters = function () { + if (!!(this.kind && 8216 /* SomeInstantiatableType */) && this.isNamedTypeSymbol() && !this.isTypeParameter()) { + return this.getTypeParameters(); + } + + if (!this._allowedToReferenceTypeParameters) { + this._allowedToReferenceTypeParameters = TypeScript.PullInstantiationHelpers.getAllowedToReferenceTypeParametersFromDecl(this.getDeclarations()[0]); + } + + return this._allowedToReferenceTypeParameters; + }; + PullTypeSymbol.prototype.isGeneric = function () { return (this._typeParameters && this._typeParameters.length > 0) || this._hasGenericSignature || this._hasGenericMember || this.isArrayNamedTypeReference(); }; - PullTypeSymbol.prototype.canUseSimpleInstantiationCache = function (substitutingTypes) { - return substitutingTypes.length === 1 && substitutingTypes[0].kind !== 8388608 /* ObjectType */; - }; - - PullTypeSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { - if (!substitutingTypes || !substitutingTypes.length) { - return; + PullTypeSymbol.prototype.canUseSimpleInstantiationCache = function (typeArgumentMap) { + if (this.isTypeParameter()) { + return true; } - if (this.canUseSimpleInstantiationCache(substitutingTypes)) { + var typeParameters = this.getTypeParameters(); + return typeArgumentMap && this.isNamedTypeSymbol() && typeParameters.length === 1 && typeArgumentMap[typeParameters[0].pullSymbolID].kind !== 8388608 /* ObjectType */; + }; + + PullTypeSymbol.prototype.getSimpleInstantiationCacheId = function (typeArgumentMap) { + if (this.isTypeParameter()) { + return typeArgumentMap[0].pullSymbolID; + } + + return typeArgumentMap[this.getTypeParameters()[0].pullSymbolID].pullSymbolID; + }; + + PullTypeSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, typeArgumentMap) { + if (this.canUseSimpleInstantiationCache(typeArgumentMap)) { if (!this._simpleInstantiationCache) { this._simpleInstantiationCache = []; } - this._simpleInstantiationCache[substitutingTypes[0].pullSymbolID] = specializedVersionOfThisType; + this._simpleInstantiationCache[this.getSimpleInstantiationCacheId(typeArgumentMap)] = specializedVersionOfThisType; } else { if (!this._complexInstantiationCache) { this._complexInstantiationCache = TypeScript.createIntrinsicsObject(); } - this._complexInstantiationCache[getIDForTypeSubstitutions(substitutingTypes)] = specializedVersionOfThisType; + this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)] = specializedVersionOfThisType; } if (!this._specializedVersionsOfThisType) { @@ -36935,25 +37202,25 @@ var TypeScript; this._specializedVersionsOfThisType.push(specializedVersionOfThisType); }; - PullTypeSymbol.prototype.getSpecialization = function (substitutingTypes) { - if (!substitutingTypes || !substitutingTypes.length) { - return null; - } - - if (this.canUseSimpleInstantiationCache(substitutingTypes)) { + PullTypeSymbol.prototype.getSpecialization = function (typeArgumentMap) { + if (this.canUseSimpleInstantiationCache(typeArgumentMap)) { if (!this._simpleInstantiationCache) { return null; } - var result = this._simpleInstantiationCache[substitutingTypes[0].pullSymbolID]; - return result ? result : null; + var result = this._simpleInstantiationCache[this.getSimpleInstantiationCacheId(typeArgumentMap)]; + return result || null; } else { if (!this._complexInstantiationCache) { return null; } - var result = this._complexInstantiationCache[getIDForTypeSubstitutions(substitutingTypes)]; - return result ? result : null; + if (this.getAllowedToReferenceTypeParameters().length == 0) { + return this; + } + + var result = this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)]; + return result || null; } }; @@ -36973,13 +37240,11 @@ var TypeScript; return this.getTypeParameters(); }; - PullTypeSymbol.prototype.addCallSignature = function (callSignature) { + PullTypeSymbol.prototype.addCallSignaturePrerequisite = function (callSignature) { if (!this._callSignatures) { this._callSignatures = []; } - this._callSignatures[this._callSignatures.length] = callSignature; - if (callSignature.isGeneric()) { this._hasGenericSignature = true; } @@ -36987,13 +37252,26 @@ var TypeScript; callSignature.functionType = this; }; - PullTypeSymbol.prototype.addConstructSignature = function (constructSignature) { + PullTypeSymbol.prototype.appendCallSignature = function (callSignature) { + this.addCallSignaturePrerequisite(callSignature); + this._callSignatures.push(callSignature); + }; + + PullTypeSymbol.prototype.insertCallSignatureAtIndex = function (callSignature, index) { + this.addCallSignaturePrerequisite(callSignature); + TypeScript.Debug.assert(index <= this._callSignatures.length); + if (index === this._callSignatures.length) { + this._callSignatures.push(callSignature); + } else { + this._callSignatures.splice(index, 0, callSignature); + } + }; + + PullTypeSymbol.prototype.addConstructSignaturePrerequisite = function (constructSignature) { if (!this._constructSignatures) { this._constructSignatures = []; } - this._constructSignatures[this._constructSignatures.length] = constructSignature; - if (constructSignature.isGeneric()) { this._hasGenericSignature = true; } @@ -37001,6 +37279,21 @@ var TypeScript; constructSignature.functionType = this; }; + PullTypeSymbol.prototype.appendConstructSignature = function (constructSignature) { + this.addConstructSignaturePrerequisite(constructSignature); + this._constructSignatures.push(constructSignature); + }; + + PullTypeSymbol.prototype.insertConstructSignatureAtIndex = function (constructSignature, index) { + this.addConstructSignaturePrerequisite(constructSignature); + TypeScript.Debug.assert(index <= this._constructSignatures.length); + if (index === this._constructSignatures.length) { + this._constructSignatures.push(constructSignature); + } else { + this._constructSignatures.splice(index, 0, constructSignature); + } + }; + PullTypeSymbol.prototype.addIndexSignature = function (indexSignature) { if (!this._indexSignatures) { this._indexSignatures = []; @@ -37015,30 +37308,14 @@ var TypeScript; indexSignature.functionType = this; }; - PullTypeSymbol.prototype.addUnhiddenSignaturesFromBaseType = function (derivedTypeSignatures, baseTypeSignatures, signaturesBeingAggregated) { - if (!derivedTypeSignatures) { - signaturesBeingAggregated.push.apply(signaturesBeingAggregated, baseTypeSignatures); - return; - } - - var resolver = this._getResolver(); - for (var i = 0; i < baseTypeSignatures.length; i++) { - var baseSignature = baseTypeSignatures[i]; - - var signatureIsHidden = TypeScript.ArrayUtilities.any(derivedTypeSignatures, function (sig) { - return resolver.signaturesAreIdentical(baseSignature, sig, false); - }); - - if (!signatureIsHidden) { - signaturesBeingAggregated.push(baseSignature); - } - } - }; - PullTypeSymbol.prototype.hasOwnCallSignatures = function () { return this._callSignatures !== null; }; + PullTypeSymbol.prototype.getOwnCallSignatures = function () { + return this._callSignatures || TypeScript.sentinelEmptyArray; + }; + PullTypeSymbol.prototype.getCallSignatures = function () { if (this._allCallSignatures) { return this._allCallSignatures; @@ -37056,7 +37333,7 @@ var TypeScript; continue; } - this.addUnhiddenSignaturesFromBaseType(this._callSignatures, this._extendedTypes[i].getCallSignatures(), signatures); + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._callSignatures, this._extendedTypes[i].getCallSignatures(), signatures); } } @@ -37069,6 +37346,10 @@ var TypeScript; return this._constructSignatures !== null; }; + PullTypeSymbol.prototype.getOwnConstructSignatures = function () { + return this._constructSignatures || TypeScript.sentinelEmptyArray; + }; + PullTypeSymbol.prototype.getConstructSignatures = function () { var signatures = []; @@ -37082,7 +37363,7 @@ var TypeScript; continue; } - this.addUnhiddenSignaturesFromBaseType(this._constructSignatures, this._extendedTypes[i].getConstructSignatures(), signatures); + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._constructSignatures, this._extendedTypes[i].getConstructSignatures(), signatures); } } @@ -37114,7 +37395,7 @@ var TypeScript; continue; } - this.addUnhiddenSignaturesFromBaseType(this._indexSignatures, this._extendedTypes[i].getIndexSignatures(), signatures); + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._indexSignatures, this._extendedTypes[i].getIndexSignatures(), signatures); } } @@ -37123,6 +37404,45 @@ var TypeScript; return signatures; }; + PullTypeSymbol.prototype.getIndexSignaturesOfAugmentedType = function (resolver, globalFunctionInterface, globalObjectInterface) { + if (!this._allIndexSignaturesOfAugmentedType) { + var initialIndexSignatures = this.getIndexSignatures(); + var shouldAddFunctionSignatures = false; + var shouldAddObjectSignatures = false; + + if (globalFunctionInterface && this.isFunctionType() && this !== globalFunctionInterface) { + var functionIndexSignatures = globalFunctionInterface.getIndexSignatures(); + if (functionIndexSignatures.length) { + shouldAddFunctionSignatures = true; + } + } + + if (globalObjectInterface && this !== globalObjectInterface) { + var objectIndexSignatures = globalObjectInterface.getIndexSignatures(); + if (objectIndexSignatures.length) { + shouldAddObjectSignatures = true; + } + } + + if (shouldAddFunctionSignatures || shouldAddObjectSignatures) { + this._allIndexSignaturesOfAugmentedType = initialIndexSignatures.slice(0); + if (shouldAddFunctionSignatures) { + resolver._addUnhiddenSignaturesFromBaseType(initialIndexSignatures, functionIndexSignatures, this._allIndexSignaturesOfAugmentedType); + } + if (shouldAddObjectSignatures) { + if (shouldAddFunctionSignatures) { + initialIndexSignatures = initialIndexSignatures.concat(functionIndexSignatures); + } + resolver._addUnhiddenSignaturesFromBaseType(initialIndexSignatures, objectIndexSignatures, this._allIndexSignaturesOfAugmentedType); + } + } else { + this._allIndexSignaturesOfAugmentedType = initialIndexSignatures; + } + } + + return this._allIndexSignaturesOfAugmentedType; + }; + PullTypeSymbol.prototype.addImplementedType = function (implementedType) { if (!implementedType) { return; @@ -37293,8 +37613,8 @@ var TypeScript; memberSymbol = this._enclosedTypeNameCache[name]; - if (memberSymbol && kind != 0 /* None */) { - memberSymbol = ((memberSymbol.kind & kind) != 0) ? memberSymbol : null; + if (memberSymbol && kind !== 0 /* None */) { + memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; } return memberSymbol; @@ -37310,8 +37630,8 @@ var TypeScript; memberSymbol = this._enclosedContainerCache[name]; - if (memberSymbol && kind != 0 /* None */) { - memberSymbol = ((memberSymbol.kind & kind) != 0) ? memberSymbol : null; + if (memberSymbol && kind !== 0 /* None */) { + memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; } return memberSymbol; @@ -37320,7 +37640,7 @@ var TypeScript; PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { var allMembers = []; - if (this._members != TypeScript.sentinelEmptyArray) { + if (this._members !== TypeScript.sentinelEmptyArray) { for (var i = 0, n = this._members.length; i < n; i++) { var member = this._members[i]; if ((member.kind & searchDeclKind) && (memberVisiblity !== 2 /* externallyVisible */ || !member.anyDeclHasFlag(2 /* Private */))) { @@ -37386,7 +37706,7 @@ var TypeScript; PullTypeSymbol.prototype.isNamedTypeSymbol = function () { var kind = this.kind; - if (kind === 2 /* Primitive */ || kind === 8 /* Class */ || kind === 4 /* Container */ || kind === 32 /* DynamicModule */ || kind === 128 /* TypeAlias */ || kind === 64 /* Enum */ || kind === 8192 /* TypeParameter */ || ((kind === 16 /* Interface */ || kind === 8388608 /* ObjectType */) && this.name != "")) { + if (kind === 2 /* Primitive */ || kind === 8 /* Class */ || kind === 4 /* Container */ || kind === 32 /* DynamicModule */ || kind === 128 /* TypeAlias */ || kind === 64 /* Enum */ || kind === 8192 /* TypeParameter */ || ((kind === 16 /* Interface */ || kind === 8388608 /* ObjectType */) && this.name !== "")) { return true; } @@ -37398,8 +37718,9 @@ var TypeScript; return s; }; - PullTypeSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) { - if (this.isArrayNamedTypeReference()) { + PullTypeSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName, shouldAllowArrayType) { + if (typeof shouldAllowArrayType === "undefined") { shouldAllowArrayType = true; } + if (this.isArrayNamedTypeReference() && shouldAllowArrayType) { var elementType = this.getElementType(); var elementMemberName = elementType ? (elementType.isArrayNamedTypeReference() || elementType.isNamedTypeSymbol() ? elementType.getScopedNameEx(scopeSymbol, false, false, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) : elementType.getMemberTypeNameEx(false, scopeSymbol, getPrettyTypeName)) : TypeScript.MemberName.create("any"); return TypeScript.MemberName.create(elementMemberName, "", "[]"); @@ -37436,8 +37757,8 @@ var TypeScript; } var functionSymbol = this.getFunctionSymbol(); - if (functionSymbol && functionSymbol.kind == 16384 /* Function */ && !TypeScript.PullHelpers.isSymbolLocal(functionSymbol)) { - return functionSymbol; + if (functionSymbol && functionSymbol.kind === 16384 /* Function */ && !TypeScript.PullHelpers.isSymbolLocal(functionSymbol)) { + return TypeScript.PullHelpers.isExportedSymbolInClodule(functionSymbol) ? null : functionSymbol; } return null; @@ -37463,10 +37784,10 @@ var TypeScript; this._inMemberTypeNameEx = true; var allMemberNames = new TypeScript.MemberNameArray(); - var curlies = !topLevel || indexSignatures.length != 0; + var curlies = !topLevel || indexSignatures.length !== 0; var delim = "; "; for (var i = 0; i < members.length; i++) { - if (members[i].kind == 65536 /* Method */ && members[i].type.hasOnlyOverloadCallSignatures()) { + if (members[i].kind === 65536 /* Method */ && members[i].type.hasOnlyOverloadCallSignatures()) { var methodCallSignatures = members[i].type.getCallSignatures(); var nameStr = members[i].getDisplayName(scopeSymbol) + (members[i].isOptional ? "?" : ""); ; @@ -37524,32 +37845,55 @@ var TypeScript; return 2 /* Closed */; }; - PullTypeSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap) { + PullTypeSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap, skipTypeArgumentCheck) { + return this.getWrappingTypeParameterID(typeParameterArgumentMap, skipTypeArgumentCheck) != 0; + }; + + PullTypeSymbol.prototype.getWrappingTypeParameterID = function (typeParameterArgumentMap, skipTypeArgumentCheck) { var type = this; - var wrapsSomeTypeParameter = false; - if (type.isTypeParameter()) { - if (typeParameterArgumentMap[type.pullSymbolID]) { - return true; + if (typeParameterArgumentMap[type.pullSymbolID] || typeParameterArgumentMap[type.getRootSymbol().pullSymbolID]) { + return type.pullSymbolID; } var constraint = type.getConstraint(); - - if (constraint && constraint.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - return true; - } - - return false; + var wrappingTypeParameterID = constraint ? constraint.getWrappingTypeParameterID(typeParameterArgumentMap) : 0; + return wrappingTypeParameterID; } if (type.inWrapCheck) { - return wrapsSomeTypeParameter; + return 0; } - type.inWrapCheck = true; + this._wrapsTypeParameterCache = this._wrapsTypeParameterCache || new TypeScript.WrapsTypeParameterCache(); + var wrappingTypeParameterID = this._wrapsTypeParameterCache.getWrapsTypeParameter(typeParameterArgumentMap); + if (wrappingTypeParameterID === undefined) { + wrappingTypeParameterID = this.getWrappingTypeParameterIDWorker(typeParameterArgumentMap, skipTypeArgumentCheck); + + this._wrapsTypeParameterCache.setWrapsTypeParameter(typeParameterArgumentMap, wrappingTypeParameterID); + } + return wrappingTypeParameterID; + }; + + PullTypeSymbol.prototype.getWrappingTypeParameterIDFromSignatures = function (signatures, typeParameterArgumentMap) { + for (var i = 0; i < signatures.length; i++) { + var wrappingTypeParameterID = signatures[i].getWrappingTypeParameterID(typeParameterArgumentMap); + if (wrappingTypeParameterID !== 0) { + return wrappingTypeParameterID; + } + } + + return 0; + }; + + PullTypeSymbol.prototype.getWrappingTypeParameterIDWorker = function (typeParameterArgumentMap, skipTypeArgumentCheck) { + var type = this; + var wrappingTypeParameterID = 0; + + if (!skipTypeArgumentCheck) { + type.inWrapCheck = true; - if (!wrapsSomeTypeParameter) { var typeArguments = type.getTypeArguments(); if (type.isGeneric() && !typeArguments) { @@ -37557,217 +37901,131 @@ var TypeScript; } if (typeArguments) { - for (var i = 0; i < typeArguments.length; i++) { - if (typeArguments[i].wrapsSomeTypeParameter(typeParameterArgumentMap)) { - wrapsSomeTypeParameter = true; - break; - } + for (var i = 0; !wrappingTypeParameterID && i < typeArguments.length; i++) { + wrappingTypeParameterID = typeArguments[i].getWrappingTypeParameterID(typeParameterArgumentMap); } } } - if (!(type.kind & 8216 /* SomeInstantiatableType */) || !type.name) { - if (!wrapsSomeTypeParameter) { - var members = type.getAllMembers(68147712 /* SomeValue */, 0 /* all */); - - for (var i = 0; i < members.length; i++) { - if (members[i].type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - wrapsSomeTypeParameter = true; - break; - } - } + if (skipTypeArgumentCheck || !(type.kind & 8216 /* SomeInstantiatableType */) || !type.name) { + var members = type.getAllMembers(68147712 /* SomeValue */, 0 /* all */); + for (var i = 0; !wrappingTypeParameterID && i < members.length; i++) { + TypeScript.PullHelpers.resolveDeclaredSymbolToUseType(members[i]); + wrappingTypeParameterID = members[i].type.getWrappingTypeParameterID(typeParameterArgumentMap); } - if (!wrapsSomeTypeParameter) { - var sigs = type.getCallSignatures(); - - for (var i = 0; i < sigs.length; i++) { - if (sigs[i].wrapsSomeTypeParameter(typeParameterArgumentMap)) { - wrapsSomeTypeParameter = true; - break; - } - } - } - - if (!wrapsSomeTypeParameter) { - sigs = type.getConstructSignatures(); - - for (var i = 0; i < sigs.length; i++) { - if (sigs[i].wrapsSomeTypeParameter(typeParameterArgumentMap)) { - wrapsSomeTypeParameter = true; - break; - } - } - } - - if (!wrapsSomeTypeParameter) { - sigs = type.getIndexSignatures(); - - for (var i = 0; i < sigs.length; i++) { - if (sigs[i].wrapsSomeTypeParameter(typeParameterArgumentMap)) { - wrapsSomeTypeParameter = true; - break; - } - } - } + wrappingTypeParameterID = wrappingTypeParameterID || this.getWrappingTypeParameterIDFromSignatures(type.getCallSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getConstructSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getIndexSignatures(), typeParameterArgumentMap); } - type.inWrapCheck = false; + if (!skipTypeArgumentCheck) { + type.inWrapCheck = false; + } - return wrapsSomeTypeParameter; + return wrappingTypeParameterID; }; - PullTypeSymbol.prototype.wrapsSomeNestedTypeIntoInfiniteExpansion = function (typeBeingWrapped) { - if (!this.isArrayNamedTypeReference() && this.isNamedTypeSymbol()) { - var knownWrapMap = TypeScript.BitMatrix.getBitMatrix(true); - var result = this._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse(typeBeingWrapped, false, knownWrapMap); - knownWrapMap.release(); - - return result; - } - - return false; + PullTypeSymbol.prototype.wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference = function (enclosingType) { + TypeScript.Debug.assert(this.isNamedTypeSymbol()); + TypeScript.Debug.assert(TypeScript.PullHelpers.getRootType(enclosingType) == enclosingType); + var knownWrapMap = TypeScript.BitMatrix.getBitMatrix(true); + var wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap); + knownWrapMap.release(); + return wrapsIntoInfinitelyExpandingTypeReference; }; - PullTypeSymbol.prototype.isTypeEquivalentToRootSymbol = function () { - if (this.isTypeReference()) { - if (this.getIsSpecialized()) { - var typeArguments = this.getTypeArguments(); - var rootTypeArguments = this.getRootSymbol().getTypeArguments(); - if (typeArguments) { - for (var i = 0; i < typeArguments.length; i++) { - if (!typeArguments[i].isTypeParameter() && !(rootTypeArguments && rootTypeArguments[i] == typeArguments[i].getRootSymbol())) { - return false; - } - } - return true; - } - - return false; - } else { - return true; - } + PullTypeSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse = function (enclosingType, knownWrapMap) { + var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); + if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { + return wrapsIntoInfinitelyExpandingTypeReference; } - return false; - }; - - PullTypeSymbol.prototype.isTypeBeingWrapped = function (typeBeingWrapped) { - if (this.inWrapCheck || this == typeBeingWrapped) { - return true; - } - - if (typeBeingWrapped.isTypeEquivalentToRootSymbol()) { - return this.isTypeBeingWrapped(typeBeingWrapped.getRootSymbol()); - } - - return false; - }; - - PullTypeSymbol.prototype.anyRootTypeBeingWrapped = function (typeBeingWrapped) { - var prevRootType = this; - var rootType = this.getRootSymbol(); - while (rootType != prevRootType) { - if (rootType.isTypeBeingWrapped(typeBeingWrapped)) { - return true; - } - - prevRootType = rootType; - rootType = rootType.getRootSymbol(); - } - - return false; - }; - - PullTypeSymbol.prototype._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse = function (typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap) { - if (this.isArrayNamedTypeReference()) { - return this.getElementType()._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap); - } - - if (this.isTypeBeingWrapped(typeBeingWrapped)) { - return isCheckingTypeArgumentList; - } - - if (knownWrapMap.valueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID) != undefined) { - return knownWrapMap.valueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID); - } - - if (this.isPrimitive() || this.isTypeParameter()) { + if (this.inWrapInfiniteExpandingReferenceCheck) { return false; } - this.inWrapCheck = true; + this.inWrapInfiniteExpandingReferenceCheck = true; + wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); + knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); + this.inWrapInfiniteExpandingReferenceCheck = false; - var wrapsSomeWrappedTypeParameter = false; - - knownWrapMap.setValueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID, false); - - wrapsSomeWrappedTypeParameter = this._wrapsSomeNestedTypeIntoInfiniteExpansionWorker(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap); - - knownWrapMap.setValueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID, wrapsSomeWrappedTypeParameter); - - this.inWrapCheck = false; - - return wrapsSomeWrappedTypeParameter; + return wrapsIntoInfinitelyExpandingTypeReference; }; - PullTypeSymbol.prototype._wrapsSomeNestedTypeIntoInfiniteExpansionWorker = function (typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap) { + PullTypeSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker = function (enclosingType, knownWrapMap) { + var thisRootType = TypeScript.PullHelpers.getRootType(this); + + if (thisRootType != enclosingType) { + var thisIsNamedType = this.isNamedTypeSymbol(); + + if (thisIsNamedType) { + if (thisRootType.inWrapInfiniteExpandingReferenceCheck) { + return false; + } + + thisRootType.inWrapInfiniteExpandingReferenceCheck = true; + } + + var wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceStructure(enclosingType, knownWrapMap); + + if (thisIsNamedType) { + thisRootType.inWrapInfiniteExpandingReferenceCheck = false; + } + + return wrapsIntoInfinitelyExpandingTypeReference; + } + + var enclosingTypeParameters = enclosingType.getTypeParameters(); var typeArguments = this.getTypeArguments(); - if (typeArguments) { - for (var i = 0; i < typeArguments.length; i++) { - if (typeArguments[i]._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse(typeBeingWrapped, true, knownWrapMap)) { - return true; - } + for (var i = 0; i < typeArguments.length; i++) { + if (TypeScript.ArrayUtilities.contains(enclosingTypeParameters, typeArguments[i])) { + continue; } - } - if (this.anyRootTypeBeingWrapped(typeBeingWrapped)) { - if (isCheckingTypeArgumentList && this.isTypeReference() && !this.getIsSpecialized()) { + if (typeArguments[i].wrapsSomeTypeParameter(this.getTypeParameterArgumentMap())) { return true; } - - return false; - } else if (!this.isNamedTypeSymbol() || this.isGeneric()) { - var isTypeEquivalentToRootSymbol = this.isTypeEquivalentToRootSymbol(); - var rootType = TypeScript.PullHelpers.getRootType(this); - if (isTypeEquivalentToRootSymbol) { - rootType.inWrapCheck = true; - } - - var members = this.getAllMembers(68147712 /* SomeValue */, 0 /* all */); - for (var i = 0; i < members.length; i++) { - if (members[i].type && members[i].type._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap)) { - return true; - } - } - - var sigs = this.getCallSignatures(); - for (var i = 0; i < sigs.length; i++) { - if (sigs[i].wrapsSomeNestedTypeIntoInfiniteExpansion(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap)) { - return true; - } - } - - sigs = this.getConstructSignatures(); - for (var i = 0; i < sigs.length; i++) { - if (sigs[i].wrapsSomeNestedTypeIntoInfiniteExpansion(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap)) { - return true; - } - } - - sigs = this.getIndexSignatures(); - for (var i = 0; i < sigs.length; i++) { - if (sigs[i].wrapsSomeNestedTypeIntoInfiniteExpansion(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap)) { - return true; - } - } - - if (isTypeEquivalentToRootSymbol) { - rootType.inWrapCheck = false; - } - - return false; } + + return false; + }; + + PullTypeSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceStructure = function (enclosingType, knownWrapMap) { + var members = this.getAllMembers(68147712 /* SomeValue */, 0 /* all */); + for (var i = 0; i < members.length; i++) { + if (members[i].type && members[i].type._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; + } + } + + var sigs = this.getCallSignatures(); + for (var i = 0; i < sigs.length; i++) { + if (sigs[i]._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference(enclosingType, knownWrapMap)) { + return true; + } + } + + sigs = this.getConstructSignatures(); + for (var i = 0; i < sigs.length; i++) { + if (sigs[i]._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference(enclosingType, knownWrapMap)) { + return true; + } + } + + sigs = this.getIndexSignatures(); + for (var i = 0; i < sigs.length; i++) { + if (sigs[i]._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference(enclosingType, knownWrapMap)) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.widenedType = function (resolver, ast, context) { + if (!this._widenedType) { + this._widenedType = resolver.widenType(this, ast, context); + } + return this._widenedType; }; return PullTypeSymbol; })(PullSymbol); @@ -37781,7 +38039,15 @@ var TypeScript; this.isResolved = true; } PullPrimitiveTypeSymbol.prototype.isAny = function () { - return this.name === "any"; + return !this.isStringConstant() && this.name === "any"; + }; + + PullPrimitiveTypeSymbol.prototype.isNull = function () { + return !this.isStringConstant() && this.name === "null"; + }; + + PullPrimitiveTypeSymbol.prototype.isUndefined = function () { + return !this.isStringConstant() && this.name === "undefined"; }; PullPrimitiveTypeSymbol.prototype.isStringConstant = function () { @@ -37790,6 +38056,14 @@ var TypeScript; PullPrimitiveTypeSymbol.prototype.setUnresolved = function () { }; + + PullPrimitiveTypeSymbol.prototype.getDisplayName = function () { + if (this.isNull() || this.isUndefined()) { + return "any"; + } else { + return _super.prototype.getDisplayName.call(this); + } + }; return PullPrimitiveTypeSymbol; })(PullTypeSymbol); TypeScript.PullPrimitiveTypeSymbol = PullPrimitiveTypeSymbol; @@ -37808,26 +38082,31 @@ var TypeScript; var PullErrorTypeSymbol = (function (_super) { __extends(PullErrorTypeSymbol, _super); - function PullErrorTypeSymbol(anyType, name) { + function PullErrorTypeSymbol(_anyType, name) { _super.call(this, name); - this.anyType = anyType; + this._anyType = _anyType; + TypeScript.Debug.assert(this._anyType); this.isResolved = true; } PullErrorTypeSymbol.prototype.isError = function () { return true; }; + PullErrorTypeSymbol.prototype._getResolver = function () { + return this._anyType._getResolver(); + }; + PullErrorTypeSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - return this.anyType.getName(scopeSymbol, useConstraintInName); + return this._anyType.getName(scopeSymbol, useConstraintInName); }; PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - return this.anyType.getName(scopeSymbol, useConstraintInName); + return this._anyType.getName(scopeSymbol, useConstraintInName); }; PullErrorTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - return this.anyType.getName(scopeSymbol, useConstraintInName); + return this._anyType.getName(scopeSymbol, useConstraintInName); }; return PullErrorTypeSymbol; })(PullPrimitiveTypeSymbol); @@ -37887,7 +38166,7 @@ var TypeScript; return false; } - if (!containerSymbol.isAlias() && containerSymbol.type == symbol) { + if (!containerSymbol.isAlias() && containerSymbol.type === symbol) { return true; } @@ -37896,7 +38175,7 @@ var TypeScript; var typeExportSymbol = moduleSymbol.getExportAssignedTypeSymbol(); var containerExportSymbol = moduleSymbol.getExportAssignedContainerSymbol(); if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { - return valueExportSymbol == symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerSymbol.usedAsSymbol(containerExportSymbol, symbol); + return valueExportSymbol === symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerSymbol.usedAsSymbol(containerExportSymbol, symbol); } return false; @@ -37918,8 +38197,15 @@ var TypeScript; this._assignedContainer = null; this._isUsedAsValue = false; this._typeUsedExternally = false; + this._isUsedInExportAlias = false; this.retrievingExportAssignment = false; + this.linkedAliasSymbols = null; } + PullTypeAliasSymbol.prototype.isUsedInExportedAlias = function () { + this._resolveDeclaredSymbol(); + return this._isUsedInExportAlias; + }; + PullTypeAliasSymbol.prototype.typeUsedExternally = function () { this._resolveDeclaredSymbol(); return this._typeUsedExternally; @@ -37930,19 +38216,33 @@ var TypeScript; return this._isUsedAsValue; }; - PullTypeAliasSymbol.prototype.setTypeUsedExternally = function (value) { - this._typeUsedExternally = value; + PullTypeAliasSymbol.prototype.setTypeUsedExternally = function () { + this._typeUsedExternally = true; }; - PullTypeAliasSymbol.prototype.setIsUsedAsValue = function (value) { - this._isUsedAsValue = value; + PullTypeAliasSymbol.prototype.setIsUsedInExportedAlias = function () { + this._isUsedInExportAlias = true; + if (this.linkedAliasSymbols) { + this.linkedAliasSymbols.forEach(function (s) { + return s.setIsUsedInExportedAlias(); + }); + } + }; - this._resolveDeclaredSymbol(); - var resolver = this._getResolver(); - var importDeclStatement = resolver.semanticInfoChain.getASTForDecl(this.getDeclarations()[0]); - var aliasSymbol = resolver.semanticInfoChain.getAliasSymbolForAST(importDeclStatement.moduleReference); - if (aliasSymbol) { - aliasSymbol.setIsUsedAsValue(value); + PullTypeAliasSymbol.prototype.addLinkedAliasSymbol = function (contingentValueSymbol) { + if (!this.linkedAliasSymbols) { + this.linkedAliasSymbols = [contingentValueSymbol]; + } else { + this.linkedAliasSymbols.push(contingentValueSymbol); + } + }; + + PullTypeAliasSymbol.prototype.setIsUsedAsValue = function () { + this._isUsedAsValue = true; + if (this.linkedAliasSymbols) { + this.linkedAliasSymbols.forEach(function (s) { + return s.setIsUsedAsValue(); + }); } }; @@ -38005,7 +38305,7 @@ var TypeScript; this.retrievingExportAssignment = true; var sym = this._assignedType.getExportAssignedTypeSymbol(); this.retrievingExportAssignment = false; - } else if (this._assignedType != this._assignedContainer) { + } else if (this._assignedType !== this._assignedContainer) { return this._assignedType; } } @@ -38110,31 +38410,15 @@ var TypeScript; })(PullTypeSymbol); TypeScript.PullTypeAliasSymbol = PullTypeAliasSymbol; - var PullDefinitionSignatureSymbol = (function (_super) { - __extends(PullDefinitionSignatureSymbol, _super); - function PullDefinitionSignatureSymbol() { - _super.apply(this, arguments); - } - PullDefinitionSignatureSymbol.prototype.isDefinition = function () { - return true; - }; - return PullDefinitionSignatureSymbol; - })(PullSignatureSymbol); - TypeScript.PullDefinitionSignatureSymbol = PullDefinitionSignatureSymbol; - var PullTypeParameterSymbol = (function (_super) { __extends(PullTypeParameterSymbol, _super); - function PullTypeParameterSymbol(name, _isFunctionTypeParameter) { + function PullTypeParameterSymbol(name) { _super.call(this, name, 8192 /* TypeParameter */); - this._isFunctionTypeParameter = _isFunctionTypeParameter; this._constraint = null; } PullTypeParameterSymbol.prototype.isTypeParameter = function () { return true; }; - PullTypeParameterSymbol.prototype.isFunctionTypeParameter = function () { - return this._isFunctionTypeParameter; - }; PullTypeParameterSymbol.prototype.setConstraint = function (constraintType) { this._constraint = constraintType; @@ -38144,6 +38428,34 @@ var TypeScript; return this._constraint; }; + PullTypeParameterSymbol.prototype.getBaseConstraint = function (semanticInfoChain) { + var preBaseConstraint = this.getConstraintRecursively({}); + TypeScript.Debug.assert(preBaseConstraint === null || !preBaseConstraint.isTypeParameter()); + return preBaseConstraint || semanticInfoChain.emptyTypeSymbol; + }; + + PullTypeParameterSymbol.prototype.getConstraintRecursively = function (visitedTypeParameters) { + var constraint = this.getConstraint(); + + if (constraint) { + if (constraint.isTypeParameter()) { + var constraintAsTypeParameter = constraint; + if (!visitedTypeParameters[constraintAsTypeParameter.pullSymbolID]) { + visitedTypeParameters[constraintAsTypeParameter.pullSymbolID] = constraintAsTypeParameter; + return constraintAsTypeParameter.getConstraintRecursively(visitedTypeParameters); + } + } else { + return constraint; + } + } + + return null; + }; + + PullTypeParameterSymbol.prototype.getDefaultConstraint = function (semanticInfoChain) { + return this._constraint || semanticInfoChain.emptyTypeSymbol; + }; + PullTypeParameterSymbol.prototype.getCallSignatures = function () { if (this._constraint) { return this._constraint.getCallSignatures(); @@ -38264,80 +38576,79 @@ var TypeScript; })(PullSymbol); TypeScript.PullAccessorSymbol = PullAccessorSymbol; - function getIDForTypeSubstitutions(types) { + function getIDForTypeSubstitutions(instantiatingTypeOrSignature, typeArgumentMap) { var substitution = ""; var members = null; - for (var i = 0; i < types.length; i++) { - if (types[i].kind !== 8388608 /* ObjectType */) { - substitution += types[i].pullSymbolID + "#"; - } else { - var structure = getIDForTypeSubstitutionsFromObjectType(types[i]); - - if (structure) { - substitution += structure; - } else { - substitution += types[i].pullSymbolID + "#"; - } + var allowedToReferenceTypeParameters = instantiatingTypeOrSignature.getAllowedToReferenceTypeParameters(); + for (var i = 0; i < allowedToReferenceTypeParameters.length; i++) { + var typeParameter = allowedToReferenceTypeParameters[i]; + var typeParameterID = typeParameter.pullSymbolID; + var typeArg = typeArgumentMap[typeParameterID]; + if (!typeArg) { + typeArg = typeParameter; } + substitution += typeParameterID + ":" + getIDForTypeSubstitutionsOfType(typeArg); } return substitution; } TypeScript.getIDForTypeSubstitutions = getIDForTypeSubstitutions; - function getIDForTypeSubstitutionsFromObjectType(type) { - var structure = ""; - - if (type.isResolved) { - var members = type.getMembers(); - if (members && members.length) { - for (var j = 0; j < members.length; j++) { - structure += members[j].name + "@" + getIDForTypeSubstitutions([members[j].type]); - } - } - - var callSignatures = type.getCallSignatures(); - if (callSignatures && callSignatures.length) { - for (var j = 0; j < callSignatures.length; j++) { - structure += getIDForTypeSubstitutionFromSignature(callSignatures[j]); - } - } - - var constructSignatures = type.getConstructSignatures(); - if (constructSignatures && constructSignatures.length) { - for (var j = 0; j < constructSignatures.length; j++) { - structure += "new" + getIDForTypeSubstitutionFromSignature(constructSignatures[j]); - } - } - - var indexSignatures = type.getIndexSignatures(); - if (indexSignatures && indexSignatures.length) { - for (var j = 0; j < indexSignatures.length; j++) { - structure += "[]" + getIDForTypeSubstitutionFromSignature(indexSignatures[j]); - } - } + function getIDForTypeSubstitutionsOfType(type) { + var structure; + if (type.isError()) { + structure = "E" + getIDForTypeSubstitutionsOfType(type._anyType); + } else if (!type.isNamedTypeSymbol()) { + structure = getIDForTypeSubstitutionsFromObjectType(type); } - if (structure !== "") { - return "{" + structure + "}"; + if (!structure) { + structure = type.pullSymbolID + "#"; + } + + return structure; + } + + function getIDForTypeSubstitutionsFromObjectType(type) { + if (type.isResolved) { + var getIDForTypeSubStitutionWalker = new GetIDForTypeSubStitutionWalker(); + TypeScript.PullHelpers.walkPullTypeSymbolStructure(type, getIDForTypeSubStitutionWalker); } return null; } - function getIDForTypeSubstitutionFromSignature(signature) { - var structure = "("; - var parameters = signature.parameters; - if (parameters && parameters.length) { - for (var k = 0; k < parameters.length; k++) { - structure += parameters[k].name + "@" + getIDForTypeSubstitutions([parameters[k].type]); - } + var GetIDForTypeSubStitutionWalker = (function () { + function GetIDForTypeSubStitutionWalker() { + this.structure = ""; } - - structure += ")" + getIDForTypeSubstitutions([signature.returnType]); - return structure; - } + GetIDForTypeSubStitutionWalker.prototype.memberSymbolWalk = function (memberSymbol) { + this.structure += memberSymbol.name + "@" + getIDForTypeSubstitutionsOfType(memberSymbol.type); + return true; + }; + GetIDForTypeSubStitutionWalker.prototype.callSignatureWalk = function (signatureSymbol) { + this.structure += "("; + return true; + }; + GetIDForTypeSubStitutionWalker.prototype.constructSignatureWalk = function (signatureSymbol) { + this.structure += "new("; + return true; + }; + GetIDForTypeSubStitutionWalker.prototype.indexSignatureWalk = function (signatureSymbol) { + this.structure += "[]("; + return true; + }; + GetIDForTypeSubStitutionWalker.prototype.signatureParameterWalk = function (parameterSymbol) { + this.structure += parameterSymbol.name + "@" + getIDForTypeSubstitutionsOfType(parameterSymbol.type); + return true; + }; + GetIDForTypeSubStitutionWalker.prototype.signatureReturnTypeWalk = function (returnType) { + this.structure += ")" + getIDForTypeSubstitutionsOfType(returnType); + return true; + }; + return GetIDForTypeSubStitutionWalker; + })(); (function (GetAllMembersVisiblity) { GetAllMembersVisiblity[GetAllMembersVisiblity["all"] = 0] = "all"; @@ -38349,38 +38660,311 @@ var TypeScript; var GetAllMembersVisiblity = TypeScript.GetAllMembersVisiblity; })(TypeScript || (TypeScript = {})); var TypeScript; +(function (TypeScript) { + var PullTypeEnclosingTypeWalker = (function () { + function PullTypeEnclosingTypeWalker() { + this.currentSymbols = null; + } + PullTypeEnclosingTypeWalker.prototype.getEnclosingType = function () { + if (this.currentSymbols && this.currentSymbols.length > 0) { + return this.currentSymbols[0]; + } + + return null; + }; + + PullTypeEnclosingTypeWalker.prototype._canWalkStructure = function () { + var enclosingType = this.getEnclosingType(); + return !!enclosingType && enclosingType.isGeneric(); + }; + + PullTypeEnclosingTypeWalker.prototype._getCurrentSymbol = function () { + if (this.currentSymbols && this.currentSymbols.length) { + return this.currentSymbols[this.currentSymbols.length - 1]; + } + + return null; + }; + + PullTypeEnclosingTypeWalker.prototype.getGenerativeClassification = function () { + if (this._canWalkStructure()) { + var currentType = this.currentSymbols[this.currentSymbols.length - 1]; + if (!currentType) { + return 0 /* Unknown */; + } + + var variableNeededToFixNodeJitterBug = this.getEnclosingType(); + + return currentType.getGenerativeTypeClassification(variableNeededToFixNodeJitterBug); + } + + return 2 /* Closed */; + }; + + PullTypeEnclosingTypeWalker.prototype._pushSymbol = function (symbol) { + return this.currentSymbols.push(symbol); + }; + + PullTypeEnclosingTypeWalker.prototype._popSymbol = function () { + return this.currentSymbols.pop(); + }; + + PullTypeEnclosingTypeWalker.prototype._setEnclosingTypeOfParentDecl = function (decl, setSignature) { + var parentDecl = decl.getParentDecl(); + if (parentDecl) { + if (parentDecl.kind & 8216 /* SomeInstantiatableType */) { + this._setEnclosingTypeWorker(parentDecl.getSymbol(), true); + } else { + this._setEnclosingTypeOfParentDecl(parentDecl, true); + } + + if (this._canWalkStructure()) { + var symbol = decl.getSymbol(); + if (symbol) { + if (symbol.kind == 2048 /* Parameter */ || symbol.kind == 4096 /* Property */ || symbol.kind == 65536 /* Method */ || symbol.kind == 32768 /* ConstructorMethod */ || symbol.kind == 131072 /* FunctionExpression */) { + symbol = symbol.type; + } + + this._pushSymbol(symbol); + } + + if (setSignature) { + var signature = decl.getSignatureSymbol(); + if (signature) { + this._pushSymbol(signature); + } + } + } + } + }; + + PullTypeEnclosingTypeWalker.prototype._setEnclosingTypeWorker = function (symbol, setSignature) { + if (symbol.isType() && symbol.isNamedTypeSymbol()) { + this.currentSymbols = [TypeScript.PullHelpers.getRootType(symbol)]; + return; + } + + var decls = symbol.getDeclarations(); + for (var i = 0; i < decls.length; i++) { + var decl = decls[i]; + this._setEnclosingTypeOfParentDecl(decl, setSignature); + if (this._canWalkStructure()) { + return; + } + } + }; + + PullTypeEnclosingTypeWalker.prototype.setCurrentSymbol = function (symbol) { + TypeScript.Debug.assert(this._canWalkStructure()); + this.currentSymbols[this.currentSymbols.length - 1] = symbol; + }; + + PullTypeEnclosingTypeWalker.prototype.startWalkingType = function (symbol) { + var currentSymbols = this.currentSymbols; + + var setEnclosingType = !this.getEnclosingType() || symbol.isNamedTypeSymbol(); + if (setEnclosingType) { + this.currentSymbols = null; + this.setEnclosingType(symbol); + } + return currentSymbols; + }; + + PullTypeEnclosingTypeWalker.prototype.endWalkingType = function (currentSymbolsWhenStartedWalkingTypes) { + this.currentSymbols = currentSymbolsWhenStartedWalkingTypes; + }; + + PullTypeEnclosingTypeWalker.prototype.setEnclosingType = function (symbol) { + TypeScript.Debug.assert(!this.getEnclosingType()); + this._setEnclosingTypeWorker(symbol, symbol.isSignature()); + }; + + PullTypeEnclosingTypeWalker.prototype.walkMemberType = function (memberName, resolver) { + if (this._canWalkStructure()) { + var currentType = this._getCurrentSymbol(); + var memberSymbol = currentType ? resolver._getNamedPropertySymbolOfAugmentedType(memberName, currentType) : null; + this._pushSymbol(memberSymbol ? memberSymbol.type : null); + } + }; + + PullTypeEnclosingTypeWalker.prototype.postWalkMemberType = function () { + if (this._canWalkStructure()) { + this._popSymbol(); + } + }; + + PullTypeEnclosingTypeWalker.prototype.walkSignature = function (kind, index) { + if (this._canWalkStructure()) { + var currentType = this._getCurrentSymbol(); + var signatures; + if (currentType) { + if (kind == 1048576 /* CallSignature */) { + signatures = currentType.getCallSignatures(); + } else if (kind == 2097152 /* ConstructSignature */) { + signatures = currentType.getConstructSignatures(); + } else { + signatures = currentType.getIndexSignatures(); + } + } + + this._pushSymbol(signatures ? signatures[index] : null); + } + }; + + PullTypeEnclosingTypeWalker.prototype.postWalkSignature = function () { + if (this._canWalkStructure()) { + this._popSymbol(); + } + }; + + PullTypeEnclosingTypeWalker.prototype.walkTypeArgument = function (index) { + if (this._canWalkStructure()) { + var typeArgument = null; + var currentType = this._getCurrentSymbol(); + if (currentType) { + var typeArguments = currentType.getTypeArguments(); + typeArgument = typeArguments ? typeArguments[index] : null; + } + this._pushSymbol(typeArgument); + } + }; + + PullTypeEnclosingTypeWalker.prototype.postWalkTypeArgument = function () { + if (this._canWalkStructure()) { + this._popSymbol(); + } + }; + + PullTypeEnclosingTypeWalker.prototype.walkTypeParameterConstraint = function (index) { + if (this._canWalkStructure()) { + var typeParameters; + var currentSymbol = this._getCurrentSymbol(); + if (currentSymbol) { + if (currentSymbol.isSignature()) { + typeParameters = currentSymbol.getTypeParameters(); + } else { + TypeScript.Debug.assert(currentSymbol.isType()); + typeParameters = currentSymbol.getTypeParameters(); + } + } + this._pushSymbol(typeParameters ? typeParameters[index].getConstraint() : null); + } + }; + + PullTypeEnclosingTypeWalker.prototype.postWalkTypeParameterConstraint = function () { + if (this._canWalkStructure()) { + this._popSymbol(); + } + }; + + PullTypeEnclosingTypeWalker.prototype.walkReturnType = function () { + if (this._canWalkStructure()) { + var currentSignature = this._getCurrentSymbol(); + this._pushSymbol(currentSignature ? currentSignature.returnType : null); + } + }; + + PullTypeEnclosingTypeWalker.prototype.postWalkReturnType = function () { + if (this._canWalkStructure()) { + this._popSymbol(); + } + }; + + PullTypeEnclosingTypeWalker.prototype.walkParameterType = function (iParam) { + if (this._canWalkStructure()) { + var currentSignature = this._getCurrentSymbol(); + this._pushSymbol(currentSignature ? currentSignature.getParameterTypeAtIndex(iParam) : null); + } + }; + PullTypeEnclosingTypeWalker.prototype.postWalkParameterType = function () { + if (this._canWalkStructure()) { + this._popSymbol(); + } + }; + + PullTypeEnclosingTypeWalker.prototype.getBothKindOfIndexSignatures = function (resolver, context, includeAugmentedType) { + if (this._canWalkStructure()) { + var currentType = this._getCurrentSymbol(); + if (currentType) { + return resolver._getBothKindsOfIndexSignatures(currentType, context, includeAugmentedType); + } + } + return null; + }; + + PullTypeEnclosingTypeWalker.prototype.walkIndexSignatureReturnType = function (indexSigInfo, useStringIndexSignature, onlySignature) { + if (this._canWalkStructure()) { + var indexSig = indexSigInfo ? (useStringIndexSignature ? indexSigInfo.stringSignature : indexSigInfo.numericSignature) : null; + this._pushSymbol(indexSig); + if (!onlySignature) { + this._pushSymbol(indexSig ? indexSig.returnType : null); + } + } + }; + + PullTypeEnclosingTypeWalker.prototype.postWalkIndexSignatureReturnType = function (onlySignature) { + if (this._canWalkStructure()) { + if (!onlySignature) { + this._popSymbol(); + } + this._popSymbol(); + } + }; + return PullTypeEnclosingTypeWalker; + })(); + TypeScript.PullTypeEnclosingTypeWalker = PullTypeEnclosingTypeWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; (function (TypeScript) { var CandidateInferenceInfo = (function () { function CandidateInferenceInfo() { this.typeParameter = null; - this.isFixed = false; + this._inferredTypeAfterFixing = null; this.inferenceCandidates = []; } CandidateInferenceInfo.prototype.addCandidate = function (candidate) { - if (!this.isFixed) { + if (!this._inferredTypeAfterFixing) { this.inferenceCandidates[this.inferenceCandidates.length] = candidate; } }; + + CandidateInferenceInfo.prototype.isFixed = function () { + return !!this._inferredTypeAfterFixing; + }; + + CandidateInferenceInfo.prototype.fixTypeParameter = function (resolver, context) { + var _this = this; + if (!this._inferredTypeAfterFixing) { + var collection = { + getLength: function () { + return _this.inferenceCandidates.length; + }, + getTypeAtIndex: function (index) { + return _this.inferenceCandidates[index].type; + } + }; + + var bestCommonType = resolver.findBestCommonType(collection, context, new TypeScript.TypeComparisonInfo()); + this._inferredTypeAfterFixing = bestCommonType.widenedType(resolver, null, context); + } + }; return CandidateInferenceInfo; })(); TypeScript.CandidateInferenceInfo = CandidateInferenceInfo; - var ArgumentInferenceContext = (function () { - function ArgumentInferenceContext(resolver, argumentsOrParameters) { + var TypeArgumentInferenceContext = (function () { + function TypeArgumentInferenceContext(resolver, context, signatureBeingInferred) { + this.resolver = resolver; + this.context = context; + this.signatureBeingInferred = signatureBeingInferred; this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); this.candidateCache = []; - this.fixedParameterTypes = null; - this.resolver = null; - this.argumentASTs = null; - this.resolver = resolver; - - if (argumentsOrParameters.nonSeparatorAt != undefined) { - this.argumentASTs = argumentsOrParameters; - } else { - this.fixedParameterTypes = argumentsOrParameters; + var typeParameters = signatureBeingInferred.getTypeParameters(); + for (var i = 0; i < typeParameters.length; i++) { + this.addInferenceRoot(typeParameters[i]); } } - ArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { + TypeArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { if (this.inferenceCache.valueAt(objectType.pullSymbolID, parameterType.pullSymbolID)) { return true; } else { @@ -38389,12 +38973,12 @@ var TypeScript; } }; - ArgumentInferenceContext.prototype.resetRelationshipCache = function () { + TypeArgumentInferenceContext.prototype.resetRelationshipCache = function () { this.inferenceCache.release(); this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); }; - ArgumentInferenceContext.prototype.addInferenceRoot = function (param) { + TypeArgumentInferenceContext.prototype.addInferenceRoot = function (param) { var info = this.candidateCache[param.pullSymbolID]; if (!info) { @@ -38404,116 +38988,121 @@ var TypeScript; } }; - ArgumentInferenceContext.prototype.getInferenceInfo = function (param) { + TypeArgumentInferenceContext.prototype.getInferenceInfo = function (param) { return this.candidateCache[param.pullSymbolID]; }; - ArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate, fix) { + TypeArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate) { var info = this.getInferenceInfo(param); - if (info) { - if (candidate) { - info.addCandidate(candidate); - } - - if (!info.isFixed) { - info.isFixed = fix; - } + if (info && candidate && info.inferenceCandidates.indexOf(candidate) < 0) { + info.addCandidate(candidate); } }; - ArgumentInferenceContext.prototype.getInferenceArgumentCount = function () { - if (this.fixedParameterTypes) { - return this.fixedParameterTypes.length; - } else { - return this.argumentASTs.nonSeparatorCount(); + TypeArgumentInferenceContext.prototype.inferTypeArguments = function () { + throw TypeScript.Errors.abstract(); + }; + + TypeArgumentInferenceContext.prototype.fixTypeParameter = function (typeParameter) { + var candidateInfo = this.candidateCache[typeParameter.pullSymbolID]; + if (candidateInfo) { + candidateInfo.fixTypeParameter(this.resolver, this.context); } }; - ArgumentInferenceContext.prototype.getArgumentTypeSymbolAtIndex = function (i, context) { - TypeScript.Debug.assert(i >= 0, "invalid inference argument position"); - - if (this.fixedParameterTypes && i < this.getInferenceArgumentCount()) { - return this.fixedParameterTypes[i]; - } else if (i < this.getInferenceArgumentCount()) { - return this.resolver.resolveAST(this.argumentASTs.nonSeparatorAt(i), true, context).type; - } - - return null; - }; - - ArgumentInferenceContext.prototype.getInferenceCandidates = function () { - var inferenceCandidates = []; - - for (var infoKey in this.candidateCache) { - if (this.candidateCache.hasOwnProperty(infoKey)) { - var info = this.candidateCache[infoKey]; - - for (var i = 0; i < info.inferenceCandidates.length; i++) { - var val = []; - val[info.typeParameter.pullSymbolID] = info.inferenceCandidates[i]; - inferenceCandidates.push(val); - } - } - } - - return inferenceCandidates; - }; - - ArgumentInferenceContext.prototype.inferArgumentTypes = function (resolver, context) { - var collection; - - var bestCommonType; - + TypeArgumentInferenceContext.prototype._finalizeInferredTypeArguments = function () { var results = []; + var typeParameters = this.signatureBeingInferred.getTypeParameters(); + for (var i = 0; i < typeParameters.length; i++) { + var info = this.candidateCache[typeParameters[i].pullSymbolID]; - var unfit = false; + info.fixTypeParameter(this.resolver, this.context); - for (var infoKey in this.candidateCache) { - if (this.candidateCache.hasOwnProperty(infoKey)) { - var info = this.candidateCache[infoKey]; - - if (!info.inferenceCandidates.length) { - results[results.length] = { param: info.typeParameter, type: null }; - continue; + for (var i = 0; i < results.length; i++) { + if (results[i].type === info.typeParameter) { + results[i].type = info._inferredTypeAfterFixing; } - - collection = { - getLength: function () { - return info.inferenceCandidates.length; - }, - getTypeAtIndex: function (index) { - return info.inferenceCandidates[index].type; - } - }; - - bestCommonType = resolver.widenType(resolver.findBestCommonType(collection, context, new TypeScript.TypeComparisonInfo())); - - if (!bestCommonType) { - unfit = true; - } else { - for (var i = 0; i < results.length; i++) { - if (results[i].type == info.typeParameter) { - results[i].type = bestCommonType; - } - } - } - - results[results.length] = { param: info.typeParameter, type: bestCommonType }; } + + results.push(info._inferredTypeAfterFixing); } - return { results: results, unfit: unfit }; + return results; }; - return ArgumentInferenceContext; + + TypeArgumentInferenceContext.prototype.isInvocationInferenceContext = function () { + throw TypeScript.Errors.abstract(); + }; + return TypeArgumentInferenceContext; })(); - TypeScript.ArgumentInferenceContext = ArgumentInferenceContext; + TypeScript.TypeArgumentInferenceContext = TypeArgumentInferenceContext; + + var InvocationTypeArgumentInferenceContext = (function (_super) { + __extends(InvocationTypeArgumentInferenceContext, _super); + function InvocationTypeArgumentInferenceContext(resolver, context, signatureBeingInferred, argumentASTs) { + _super.call(this, resolver, context, signatureBeingInferred); + this.argumentASTs = argumentASTs; + } + InvocationTypeArgumentInferenceContext.prototype.isInvocationInferenceContext = function () { + return true; + }; + + InvocationTypeArgumentInferenceContext.prototype.inferTypeArguments = function () { + var _this = this; + this.signatureBeingInferred.forAllParameterTypes(this.argumentASTs.nonSeparatorCount(), function (parameterType, argumentIndex) { + var argumentAST = _this.argumentASTs.nonSeparatorAt(argumentIndex); + + _this.context.pushInferentialType(parameterType, _this); + var argumentType = _this.resolver.resolveAST(argumentAST, true, _this.context).type; + _this.resolver.relateTypeToTypeParametersWithNewEnclosingTypes(argumentType, parameterType, _this, _this.context); + _this.context.popAnyContextualType(); + + return true; + }); + + return this._finalizeInferredTypeArguments(); + }; + return InvocationTypeArgumentInferenceContext; + })(TypeArgumentInferenceContext); + TypeScript.InvocationTypeArgumentInferenceContext = InvocationTypeArgumentInferenceContext; + + var ContextualSignatureInstantiationTypeArgumentInferenceContext = (function (_super) { + __extends(ContextualSignatureInstantiationTypeArgumentInferenceContext, _super); + function ContextualSignatureInstantiationTypeArgumentInferenceContext(resolver, context, signatureBeingInferred, contextualSignature, shouldFixContextualSignatureParameterTypes) { + _super.call(this, resolver, context, signatureBeingInferred); + this.contextualSignature = contextualSignature; + this.shouldFixContextualSignatureParameterTypes = shouldFixContextualSignatureParameterTypes; + } + ContextualSignatureInstantiationTypeArgumentInferenceContext.prototype.isInvocationInferenceContext = function () { + return false; + }; + + ContextualSignatureInstantiationTypeArgumentInferenceContext.prototype.inferTypeArguments = function () { + var _this = this; + var relateTypesCallback = function (parameterTypeBeingInferred, contextualParameterType) { + if (_this.shouldFixContextualSignatureParameterTypes) { + contextualParameterType = _this.context.fixAllTypeParametersReferencedByType(contextualParameterType, _this.resolver, _this); + } + _this.resolver.relateTypeToTypeParametersWithNewEnclosingTypes(contextualParameterType, parameterTypeBeingInferred, _this, _this.context); + + return true; + }; + + this.signatureBeingInferred.forAllCorrespondingParameterTypesInThisAndOtherSignature(this.contextualSignature, relateTypesCallback); + + return this._finalizeInferredTypeArguments(); + }; + return ContextualSignatureInstantiationTypeArgumentInferenceContext; + })(TypeArgumentInferenceContext); + TypeScript.ContextualSignatureInstantiationTypeArgumentInferenceContext = ContextualSignatureInstantiationTypeArgumentInferenceContext; var PullContextualTypeContext = (function () { - function PullContextualTypeContext(contextualType, provisional, substitutions) { + function PullContextualTypeContext(contextualType, provisional, isInferentiallyTyping, typeArgumentInferenceContext) { this.contextualType = contextualType; this.provisional = provisional; - this.substitutions = substitutions; + this.isInferentiallyTyping = isInferentiallyTyping; + this.typeArgumentInferenceContext = typeArgumentInferenceContext; this.provisionallyTypedSymbols = []; this.hasProvisionalErrors = false; this.astSymbolMap = []; @@ -38548,6 +39137,8 @@ var TypeScript; this.fileName = fileName; this.contextStack = []; this.typeCheckedNodes = null; + this.enclosingTypeWalker1 = null; + this.enclosingTypeWalker2 = null; this.inBaseTypeResolution = false; if (inTypeCheck) { TypeScript.Debug.assert(fileName, "A file name must be provided if you are typechecking"); @@ -38564,11 +39155,27 @@ var TypeScript; return this.typeCheck() && !this.typeCheckedNodes.valueAt(ast.syntaxID()) && this.fileName === ast.fileName(); }; - PullTypeResolutionContext.prototype.pushContextualType = function (type, provisional, substitutions) { - this.contextStack.push(new PullContextualTypeContext(type, provisional, substitutions)); + PullTypeResolutionContext.prototype._pushAnyContextualType = function (type, provisional, isInferentiallyTyping, argContext) { + this.contextStack.push(new PullContextualTypeContext(type, provisional, isInferentiallyTyping, argContext)); }; - PullTypeResolutionContext.prototype.popContextualType = function () { + PullTypeResolutionContext.prototype.pushNewContextualType = function (type) { + this._pushAnyContextualType(type, this.inProvisionalResolution(), false, null); + }; + + PullTypeResolutionContext.prototype.propagateContextualType = function (type) { + this._pushAnyContextualType(type, this.inProvisionalResolution(), this.isInferentiallyTyping(), this.getCurrentTypeArgumentInferenceContext()); + }; + + PullTypeResolutionContext.prototype.pushInferentialType = function (type, typeArgumentInferenceContext) { + this._pushAnyContextualType(type, true, true, typeArgumentInferenceContext); + }; + + PullTypeResolutionContext.prototype.pushProvisionalType = function (type) { + this._pushAnyContextualType(type, true, false, null); + }; + + PullTypeResolutionContext.prototype.popAnyContextualType = function () { var tc = this.contextStack.pop(); tc.invalidateProvisionallyTypedSymbols(); @@ -38584,24 +39191,6 @@ var TypeScript; return this.contextStack.length ? this.contextStack[this.contextStack.length - 1].hasProvisionalErrors : false; }; - PullTypeResolutionContext.prototype.findSubstitution = function (type) { - var substitution = null; - - if (this.contextStack.length) { - for (var i = this.contextStack.length - 1; i >= 0; i--) { - if (this.contextStack[i].substitutions) { - substitution = this.contextStack[i].substitutions[type.pullSymbolID]; - - if (substitution) { - break; - } - } - } - } - - return substitution; - }; - PullTypeResolutionContext.prototype.getContextualType = function () { var context = !this.contextStack.length ? null : this.contextStack[this.contextStack.length - 1]; @@ -38612,18 +39201,44 @@ var TypeScript; return null; } - if (type.isTypeParameter() && type.getConstraint()) { - type = type.getConstraint(); - } - - var substitution = this.findSubstitution(type); - - return substitution ? substitution : type; + return type; } return null; }; + PullTypeResolutionContext.prototype.fixAllTypeParametersReferencedByType = function (type, resolver, argContext) { + var argContext = this.getCurrentTypeArgumentInferenceContext(); + if (type.wrapsSomeTypeParameter(argContext.candidateCache)) { + var typeParameterArgumentMap = []; + + for (var n in argContext.candidateCache) { + var typeParameter = argContext.candidateCache[n] && argContext.candidateCache[n].typeParameter; + if (typeParameter) { + var dummyMap = []; + dummyMap[typeParameter.pullSymbolID] = typeParameter; + if (type.wrapsSomeTypeParameter(dummyMap)) { + argContext.fixTypeParameter(typeParameter); + TypeScript.Debug.assert(argContext.candidateCache[n]._inferredTypeAfterFixing); + typeParameterArgumentMap[typeParameter.pullSymbolID] = argContext.candidateCache[n]._inferredTypeAfterFixing; + } + } + } + + return resolver.instantiateType(type, typeParameterArgumentMap); + } + + return type; + }; + + PullTypeResolutionContext.prototype.getCurrentTypeArgumentInferenceContext = function () { + return this.contextStack.length ? this.contextStack[this.contextStack.length - 1].typeArgumentInferenceContext : null; + }; + + PullTypeResolutionContext.prototype.isInferentiallyTyping = function () { + return this.contextStack.length > 0 && this.contextStack[this.contextStack.length - 1].isInferentiallyTyping; + }; + PullTypeResolutionContext.prototype.inProvisionalResolution = function () { return (!this.contextStack.length ? false : this.contextStack[this.contextStack.length - 1].provisional); }; @@ -38643,9 +39258,10 @@ var TypeScript; }; PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, type) { - var substitution = this.findSubstitution(type); - - symbol.type = substitution ? substitution : type; + if (symbol.type && symbol.type.isError() && !type.isError()) { + return; + } + symbol.type = type; if (this.contextStack.length && this.inProvisionalResolution()) { this.contextStack[this.contextStack.length - 1].recordProvisionallyTypedSymbol(symbol); @@ -38685,6 +39301,145 @@ var TypeScript; return null; }; + + PullTypeResolutionContext.prototype.startWalkingTypes = function (symbol1, symbol2) { + if (!this.enclosingTypeWalker1) { + this.enclosingTypeWalker1 = new TypeScript.PullTypeEnclosingTypeWalker(); + } + var symbolsWhenStartedWalkingTypes1 = this.enclosingTypeWalker1.startWalkingType(symbol1); + if (!this.enclosingTypeWalker2) { + this.enclosingTypeWalker2 = new TypeScript.PullTypeEnclosingTypeWalker(); + } + var symbolsWhenStartedWalkingTypes2 = this.enclosingTypeWalker2.startWalkingType(symbol2); + return { symbolsWhenStartedWalkingTypes1: symbolsWhenStartedWalkingTypes1, symbolsWhenStartedWalkingTypes2: symbolsWhenStartedWalkingTypes2 }; + }; + + PullTypeResolutionContext.prototype.endWalkingTypes = function (symbolsWhenStartedWalkingTypes) { + this.enclosingTypeWalker1.endWalkingType(symbolsWhenStartedWalkingTypes.symbolsWhenStartedWalkingTypes1); + this.enclosingTypeWalker2.endWalkingType(symbolsWhenStartedWalkingTypes.symbolsWhenStartedWalkingTypes2); + }; + + PullTypeResolutionContext.prototype.setEnclosingTypes = function (symbol1, symbol2) { + if (!this.enclosingTypeWalker1) { + this.enclosingTypeWalker1 = new TypeScript.PullTypeEnclosingTypeWalker(); + } + this.enclosingTypeWalker1.setEnclosingType(symbol1); + if (!this.enclosingTypeWalker2) { + this.enclosingTypeWalker2 = new TypeScript.PullTypeEnclosingTypeWalker(); + } + this.enclosingTypeWalker2.setEnclosingType(symbol2); + }; + + PullTypeResolutionContext.prototype.walkMemberTypes = function (memberName) { + this.enclosingTypeWalker1.walkMemberType(memberName, this.resolver); + this.enclosingTypeWalker2.walkMemberType(memberName, this.resolver); + }; + + PullTypeResolutionContext.prototype.postWalkMemberTypes = function () { + this.enclosingTypeWalker1.postWalkMemberType(); + this.enclosingTypeWalker2.postWalkMemberType(); + }; + + PullTypeResolutionContext.prototype.walkSignatures = function (kind, index, index2) { + this.enclosingTypeWalker1.walkSignature(kind, index); + this.enclosingTypeWalker2.walkSignature(kind, index2 == undefined ? index : index2); + }; + + PullTypeResolutionContext.prototype.postWalkSignatures = function () { + this.enclosingTypeWalker1.postWalkSignature(); + this.enclosingTypeWalker2.postWalkSignature(); + }; + + PullTypeResolutionContext.prototype.walkTypeParameterConstraints = function (index) { + this.enclosingTypeWalker1.walkTypeParameterConstraint(index); + this.enclosingTypeWalker2.walkTypeParameterConstraint(index); + }; + + PullTypeResolutionContext.prototype.postWalkTypeParameterConstraints = function () { + this.enclosingTypeWalker1.postWalkTypeParameterConstraint(); + this.enclosingTypeWalker2.postWalkTypeParameterConstraint(); + }; + + PullTypeResolutionContext.prototype.walkTypeArgument = function (index) { + this.enclosingTypeWalker1.walkTypeArgument(index); + this.enclosingTypeWalker2.walkTypeArgument(index); + }; + + PullTypeResolutionContext.prototype.postWalkTypeArgument = function () { + this.enclosingTypeWalker1.postWalkTypeArgument(); + this.enclosingTypeWalker2.postWalkTypeArgument(); + }; + + PullTypeResolutionContext.prototype.walkReturnTypes = function () { + this.enclosingTypeWalker1.walkReturnType(); + this.enclosingTypeWalker2.walkReturnType(); + }; + + PullTypeResolutionContext.prototype.postWalkReturnTypes = function () { + this.enclosingTypeWalker1.postWalkReturnType(); + this.enclosingTypeWalker2.postWalkReturnType(); + }; + + PullTypeResolutionContext.prototype.walkParameterTypes = function (iParam) { + this.enclosingTypeWalker1.walkParameterType(iParam); + this.enclosingTypeWalker2.walkParameterType(iParam); + }; + + PullTypeResolutionContext.prototype.postWalkParameterTypes = function () { + this.enclosingTypeWalker1.postWalkParameterType(); + this.enclosingTypeWalker2.postWalkParameterType(); + }; + + PullTypeResolutionContext.prototype.getBothKindOfIndexSignatures = function (includeAugmentedType1, includeAugmentedType2) { + var indexSigs1 = this.enclosingTypeWalker1.getBothKindOfIndexSignatures(this.resolver, this, includeAugmentedType1); + var indexSigs2 = this.enclosingTypeWalker2.getBothKindOfIndexSignatures(this.resolver, this, includeAugmentedType2); + return { indexSigs1: indexSigs1, indexSigs2: indexSigs2 }; + }; + + PullTypeResolutionContext.prototype.walkIndexSignatureReturnTypes = function (indexSigs, useStringIndexSignature1, useStringIndexSignature2, onlySignature) { + this.enclosingTypeWalker1.walkIndexSignatureReturnType(indexSigs.indexSigs1, useStringIndexSignature1, onlySignature); + this.enclosingTypeWalker2.walkIndexSignatureReturnType(indexSigs.indexSigs2, useStringIndexSignature2, onlySignature); + }; + + PullTypeResolutionContext.prototype.postWalkIndexSignatureReturnTypes = function (onlySignature) { + this.enclosingTypeWalker1.postWalkIndexSignatureReturnType(onlySignature); + this.enclosingTypeWalker2.postWalkIndexSignatureReturnType(onlySignature); + }; + + PullTypeResolutionContext.prototype.swapEnclosingTypeWalkers = function () { + var tempEnclosingWalker1 = this.enclosingTypeWalker1; + this.enclosingTypeWalker1 = this.enclosingTypeWalker2; + this.enclosingTypeWalker2 = tempEnclosingWalker1; + }; + + PullTypeResolutionContext.prototype.oneOfClassificationsIsInfinitelyExpanding = function () { + var generativeClassification1 = this.enclosingTypeWalker1.getGenerativeClassification(); + if (generativeClassification1 === 3 /* InfinitelyExpanding */) { + return true; + } + var generativeClassification2 = this.enclosingTypeWalker2.getGenerativeClassification(); + if (generativeClassification2 === 3 /* InfinitelyExpanding */) { + return true; + } + + return false; + }; + + PullTypeResolutionContext.prototype.resetEnclosingTypeWalkers = function () { + var enclosingTypeWalker1 = this.enclosingTypeWalker1; + var enclosingTypeWalker2 = this.enclosingTypeWalker2; + this.enclosingTypeWalker1 = null; + this.enclosingTypeWalker2 = null; + return { + enclosingTypeWalker1: enclosingTypeWalker1, + enclosingTypeWalker2: enclosingTypeWalker2 + }; + }; + + PullTypeResolutionContext.prototype.setEnclosingTypeWalkers = function (enclosingTypeWalkers) { + this.enclosingTypeWalker1 = enclosingTypeWalkers.enclosingTypeWalker1; + this.enclosingTypeWalker2 = enclosingTypeWalkers.enclosingTypeWalker2; + }; return PullTypeResolutionContext; })(); TypeScript.PullTypeResolutionContext = PullTypeResolutionContext; @@ -38741,20 +39496,19 @@ var TypeScript; return InheritedIndexSignatureInfo; })(); - var CompilerReservedNames; - (function (CompilerReservedNames) { - CompilerReservedNames[CompilerReservedNames["_this"] = 1] = "_this"; - CompilerReservedNames[CompilerReservedNames["_super"] = 2] = "_super"; - CompilerReservedNames[CompilerReservedNames["arguments"] = 3] = "arguments"; - CompilerReservedNames[CompilerReservedNames["_i"] = 4] = "_i"; - CompilerReservedNames[CompilerReservedNames["require"] = 5] = "require"; - CompilerReservedNames[CompilerReservedNames["exports"] = 6] = "exports"; - })(CompilerReservedNames || (CompilerReservedNames = {})); + var CompilerReservedName; + (function (CompilerReservedName) { + CompilerReservedName[CompilerReservedName["_this"] = 1] = "_this"; + CompilerReservedName[CompilerReservedName["_super"] = 2] = "_super"; + CompilerReservedName[CompilerReservedName["arguments"] = 3] = "arguments"; + CompilerReservedName[CompilerReservedName["_i"] = 4] = "_i"; + CompilerReservedName[CompilerReservedName["require"] = 5] = "require"; + CompilerReservedName[CompilerReservedName["exports"] = 6] = "exports"; + })(CompilerReservedName || (CompilerReservedName = {})); function getCompilerReservedName(name) { var nameText = name.valueText(); - var index = CompilerReservedNames[nameText]; - return CompilerReservedNames[index] ? index : undefined; + return CompilerReservedName[nameText]; } var PullTypeResolver = (function () { @@ -38776,14 +39530,11 @@ var TypeScript; this.assignableCache = TypeScript.BitMatrix.getBitMatrix(true); this.subtypeCache = TypeScript.BitMatrix.getBitMatrix(true); this.identicalCache = TypeScript.BitMatrix.getBitMatrix(true); + this.inResolvingOtherDeclsWalker = new TypeScript.PullHelpers.OtherPullDeclsWalker(); } PullTypeResolver.prototype.cachedArrayInterfaceType = function () { if (!this._cachedArrayInterfaceType) { - this._cachedArrayInterfaceType = this.getSymbolFromDeclPath("Array", [], 16 /* Interface */); - } - - if (!this._cachedArrayInterfaceType) { - this._cachedArrayInterfaceType = this.semanticInfoChain.anyTypeSymbol; + this._cachedArrayInterfaceType = this.getSymbolFromDeclPath("Array", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; } if (!this._cachedArrayInterfaceType.isResolved) { @@ -38799,7 +39550,7 @@ var TypeScript; PullTypeResolver.prototype.cachedNumberInterfaceType = function () { if (!this._cachedNumberInterfaceType) { - this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */); + this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; } if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved) { @@ -38811,7 +39562,7 @@ var TypeScript; PullTypeResolver.prototype.cachedStringInterfaceType = function () { if (!this._cachedStringInterfaceType) { - this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */); + this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; } if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved) { @@ -38823,7 +39574,7 @@ var TypeScript; PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { if (!this._cachedBooleanInterfaceType) { - this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */); + this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; } if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved) { @@ -38835,7 +39586,7 @@ var TypeScript; PullTypeResolver.prototype.cachedObjectInterfaceType = function () { if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */); + this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; } if (!this._cachedObjectInterfaceType) { @@ -38851,7 +39602,7 @@ var TypeScript; PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { if (!this._cachedFunctionInterfaceType) { - this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */); + this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; } if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved) { @@ -38863,7 +39614,7 @@ var TypeScript; PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { if (!this._cachedIArgumentsInterfaceType) { - this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */); + this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; } if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved) { @@ -38875,7 +39626,7 @@ var TypeScript; PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { if (!this._cachedRegExpInterfaceType) { - this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */); + this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; } if (this._cachedRegExpInterfaceType && !this._cachedRegExpInterfaceType.isResolved) { @@ -38888,10 +39639,10 @@ var TypeScript; PullTypeResolver.prototype.cachedFunctionArgumentsSymbol = function () { if (!this._cachedFunctionArgumentsSymbol) { this._cachedFunctionArgumentsSymbol = new TypeScript.PullSymbol("arguments", 512 /* Variable */); - this._cachedFunctionArgumentsSymbol.type = this.cachedIArgumentsInterfaceType() ? this.cachedIArgumentsInterfaceType() : this.semanticInfoChain.anyTypeSymbol; + this._cachedFunctionArgumentsSymbol.type = this.cachedIArgumentsInterfaceType() || this.semanticInfoChain.anyTypeSymbol; this._cachedFunctionArgumentsSymbol.setResolved(); - var functionArgumentsDecl = new TypeScript.PullSynthesizedDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, null, new TypeScript.TextSpan(0, 0), this.semanticInfoChain); + var functionArgumentsDecl = new TypeScript.PullSynthesizedDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, null, this.semanticInfoChain); functionArgumentsDecl.setSymbol(this._cachedFunctionArgumentsSymbol); this._cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); } @@ -38899,6 +39650,33 @@ var TypeScript; return this._cachedFunctionArgumentsSymbol; }; + PullTypeResolver.prototype.getApparentType = function (type) { + if (type.isTypeParameter()) { + var baseConstraint = type.getBaseConstraint(this.semanticInfoChain); + if (baseConstraint === this.semanticInfoChain.anyTypeSymbol) { + return this.semanticInfoChain.emptyTypeSymbol; + } else { + type = baseConstraint; + } + } + if (type.isPrimitive()) { + if (type === this.semanticInfoChain.numberTypeSymbol) { + return this.cachedNumberInterfaceType(); + } + if (type === this.semanticInfoChain.booleanTypeSymbol) { + return this.cachedBooleanInterfaceType(); + } + if (type === this.semanticInfoChain.stringTypeSymbol) { + return this.cachedStringInterfaceType(); + } + return type; + } + if (type.isEnum()) { + return this.cachedNumberInterfaceType(); + } + return type; + }; + PullTypeResolver.prototype.setTypeChecked = function (ast, context) { context.setTypeChecked(ast); }; @@ -38948,7 +39726,7 @@ var TypeScript; PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { if (!(symbol.kind & (65536 /* Method */ | 4096 /* Property */))) { - var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) != 0; + var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) !== 0; var containerType = !isContainer ? parent.getAssociatedContainerType() : parent; if (isContainer && containerType) { @@ -38963,12 +39741,32 @@ var TypeScript; return symbol; }; - PullTypeResolver.prototype.getMemberSymbol = function (symbolName, declSearchKind, parent) { + PullTypeResolver.prototype._getNamedPropertySymbolOfAugmentedType = function (symbolName, parent) { + var memberSymbol = this.getNamedPropertySymbol(symbolName, 68147712 /* SomeValue */, parent); + if (memberSymbol) { + return memberSymbol; + } + + if (this.cachedFunctionInterfaceType() && parent.isFunctionType()) { + memberSymbol = this.cachedFunctionInterfaceType().findMember(symbolName, true); + if (memberSymbol) { + return memberSymbol; + } + } + + if (this.cachedObjectInterfaceType()) { + return this.cachedObjectInterfaceType().findMember(symbolName, true); + } + + return null; + }; + + PullTypeResolver.prototype.getNamedPropertySymbol = function (symbolName, declSearchKind, parent) { var member = null; if (declSearchKind & 68147712 /* SomeValue */) { member = parent.findMember(symbolName, true); - } else if (declSearchKind & 58728539 /* SomeType */) { + } else if (declSearchKind & 58728795 /* SomeType */) { member = parent.findNestedType(symbolName); } else if (declSearchKind & 164 /* SomeContainer */) { member = parent.findNestedContainer(symbolName); @@ -38989,7 +39787,7 @@ var TypeScript; if (declSearchKind & 68147712 /* SomeValue */) { member = parent.findMember(symbolName, true); - } else if (declSearchKind & 58728539 /* SomeType */) { + } else if (declSearchKind & 58728795 /* SomeType */) { member = parent.findNestedType(symbolName); } else if (declSearchKind & 164 /* SomeContainer */) { member = parent.findNestedContainer(symbolName); @@ -39016,12 +39814,12 @@ var TypeScript; return this.getExportedMemberSymbol(member, parent); } - if ((declSearchKind & 58728539 /* SomeType */) != 0 || (declSearchKind & 68147712 /* SomeValue */) != 0) { + if ((declSearchKind & 58728795 /* SomeType */) !== 0 || (declSearchKind & 68147712 /* SomeValue */) !== 0) { childDecls = typeDeclarations[j].searchChildDecls(symbolName, 128 /* TypeAlias */); - if (childDecls.length && childDecls[0].kind == 128 /* TypeAlias */) { + if (childDecls.length && childDecls[0].kind === 128 /* TypeAlias */) { var aliasSymbol = this.getExportedMemberSymbol(childDecls[0].getSymbol(), parent); if (aliasSymbol) { - if ((declSearchKind & 58728539 /* SomeType */) != 0) { + if ((declSearchKind & 58728795 /* SomeType */) !== 0) { var typeSymbol = aliasSymbol.getExportAssignedTypeSymbol(); if (typeSymbol) { return typeSymbol; @@ -39029,9 +39827,12 @@ var TypeScript; } else { var valueSymbol = aliasSymbol.getExportAssignedValueSymbol(); if (valueSymbol) { + aliasSymbol.setIsUsedAsValue(); return valueSymbol; } } + + return aliasSymbol; } } } @@ -39040,6 +39841,7 @@ var TypeScript; }; PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { + var _this = this; var symbol = null; var decl = null; @@ -39053,6 +39855,61 @@ var TypeScript; var instanceType = null; var childSymbol = null; + var allowedContainerDeclKind = 4 /* Container */ | 32 /* DynamicModule */; + if (TypeScript.hasFlag(declSearchKind, 67108864 /* EnumMember */)) { + allowedContainerDeclKind |= 64 /* Enum */; + } + + var isAcceptableAlias = function (symbol) { + if (symbol.isAlias()) { + _this.resolveDeclaredSymbol(symbol); + if (TypeScript.hasFlag(declSearchKind, 164 /* SomeContainer */)) { + if (symbol.assignedContainer() || symbol.getExportAssignedContainerSymbol()) { + return true; + } + } else if (TypeScript.hasFlag(declSearchKind, 58728795 /* SomeType */)) { + var type = symbol.getExportAssignedTypeSymbol(); + if (type && type.kind !== 32 /* DynamicModule */) { + return true; + } + + var type = symbol.assignedType(); + if (type && type.kind !== 32 /* DynamicModule */) { + return true; + } + } else if (TypeScript.hasFlag(declSearchKind, 68147712 /* SomeValue */ & ~67108864 /* EnumMember */)) { + if (symbol.assignedType() && symbol.assignedType().isError()) { + return true; + } else if (symbol.assignedValue() || symbol.getExportAssignedValueSymbol()) { + return true; + } else { + var assignedType = symbol.assignedType(); + if (assignedType && assignedType.isContainer() && assignedType.getInstanceType()) { + return true; + } + + var decls = symbol.getDeclarations(); + var ast = decls[0].ast(); + return ast.moduleReference.kind() === 245 /* ExternalModuleReference */; + } + } + } + + return false; + }; + + var tryFindAlias = function (decl) { + var childDecls = decl.searchChildDecls(symbolName, 128 /* TypeAlias */); + + if (childDecls.length) { + var sym = childDecls[0].getSymbol(); + if (isAcceptableAlias(sym)) { + return sym; + } + } + return null; + }; + for (var i = declPath.length - 1; i >= 0; i--) { decl = declPath[i]; pathDeclKind = decl.kind; @@ -39061,30 +39918,25 @@ var TypeScript; return this.semanticInfoChain.anyTypeSymbol; } - if (pathDeclKind & (4 /* Container */ | 32 /* DynamicModule */)) { + if (pathDeclKind & allowedContainerDeclKind) { childDecls = decl.searchChildDecls(symbolName, declSearchKind); if (childDecls.length) { return childDecls[0].getSymbol(); } + var alias = tryFindAlias(decl); + if (alias) { + return alias; + } + if (declSearchKind & 68147712 /* SomeValue */) { instanceSymbol = decl.getSymbol().getInstanceSymbol(); - childDecls = decl.searchChildDecls(symbolName, 128 /* TypeAlias */); - - if (childDecls.length) { - var sym = childDecls[0].getSymbol(); - - if (sym.isAlias()) { - return sym; - } - } - if (instanceSymbol) { instanceType = instanceSymbol.type; - childSymbol = this.getMemberSymbol(symbolName, declSearchKind, instanceType); + childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, instanceType); if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { return childSymbol; @@ -39100,12 +39952,12 @@ var TypeScript; declSymbol = decl.getSymbol().type; - var childSymbol = this.getMemberSymbol(symbolName, declSearchKind, declSymbol); + var childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, declSymbol); if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { return childSymbol; } - } else if ((declSearchKind & (58728539 /* SomeType */ | 164 /* SomeContainer */)) || !(pathDeclKind & 8 /* Class */)) { + } else if ((declSearchKind & (58728795 /* SomeType */ | 164 /* SomeContainer */)) || !(pathDeclKind & 8 /* Class */)) { var candidateSymbol = null; if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === decl.getFunctionExpressionName()) { @@ -39125,23 +39977,26 @@ var TypeScript; return candidateSymbol; } - if (declSearchKind & 68147712 /* SomeValue */) { - childDecls = decl.searchChildDecls(symbolName, 128 /* TypeAlias */); - - if (childDecls.length) { - var sym = childDecls[0].getSymbol(); - - if (sym.isAlias()) { - return sym; - } - } + var alias = tryFindAlias(decl); + if (alias) { + return alias; } } } symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); + if (symbol) { + return symbol; + } - return symbol; + if (!TypeScript.hasFlag(declSearchKind, 128 /* TypeAlias */)) { + symbol = this.semanticInfoChain.findSymbol([symbolName], 128 /* TypeAlias */); + if (symbol && isAcceptableAlias(symbol)) { + return symbol; + } + } + + return null; }; PullTypeResolver.prototype.getVisibleDeclsFromDeclPath = function (declPath, declSearchKind) { @@ -39237,7 +40092,7 @@ var TypeScript; PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl) { var declPath = enclosingDecl.getParentPath(); - var declSearchKind = 58728539 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); }; @@ -39248,7 +40103,7 @@ var TypeScript; return null; } - var declSearchKind = 58728539 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; var members = contextualTypeSymbol.getAllMembers(declSearchKind, 2 /* externallyVisible */); for (var i = 0; i < members.length; i++) { @@ -39261,7 +40116,7 @@ var TypeScript; PullTypeResolver.prototype.getVisibleMembersFromExpression = function (expression, enclosingDecl, context) { var lhs = this.resolveAST(expression, false, context); - if (isTypesOnlyLocation(expression) && (lhs.kind === 8 /* Class */ || lhs.kind === 16 /* Interface */)) { + if (isTypesOnlyLocation(expression) && (lhs.kind === 8 /* Class */ || lhs.kind === 16 /* Interface */ || lhs.kind === 64 /* Enum */)) { return null; } @@ -39276,13 +40131,6 @@ var TypeScript; lhsType = lhsType.getExportAssignedTypeSymbol(); } - while (lhsType.isTypeParameter()) { - lhsType = lhsType.getConstraint(); - if (!lhsType) { - return null; - } - } - if (this.isAnyOrEquivalent(lhsType)) { return null; } @@ -39307,7 +40155,7 @@ var TypeScript; } } - var declSearchKind = 58728539 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; var members = []; @@ -39318,66 +40166,47 @@ var TypeScript; } } - if (lhsType.isTypeParameter()) { - var constraint = lhsType.getConstraint(); + lhsType = this.getApparentType(lhsType); - if (constraint) { - lhsType = constraint; - members = lhsType.getAllMembers(declSearchKind, 2 /* externallyVisible */); - } - } else { - if (lhs.kind == 67108864 /* EnumMember */) { - lhsType = this.semanticInfoChain.numberTypeSymbol; - } + if (!lhsType.isResolved) { + var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); - if (lhsType === this.semanticInfoChain.numberTypeSymbol && this.cachedNumberInterfaceType()) { - lhsType = this.cachedNumberInterfaceType(); - } else if (lhsType === this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { - lhsType = this.cachedStringInterfaceType(); - } else if (lhsType === this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { - lhsType = this.cachedBooleanInterfaceType(); - } - - if (!lhsType.isResolved) { - var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); - - if (potentiallySpecializedType != lhsType) { - if (!lhs.isType()) { - context.setTypeInContext(lhs, potentiallySpecializedType); - } - - lhsType = potentiallySpecializedType; - } - } - - members = lhsType.getAllMembers(declSearchKind, memberVisibilty); - - if (lhsType.isContainer()) { - var associatedInstance = lhsType.getInstanceSymbol(); - if (associatedInstance) { - var instanceType = associatedInstance.type; - this.resolveDeclaredSymbol(instanceType, context); - var instanceMembers = instanceType.getAllMembers(declSearchKind, memberVisibilty); - members = members.concat(instanceMembers); + if (potentiallySpecializedType !== lhsType) { + if (!lhs.isType()) { + context.setTypeInContext(lhs, potentiallySpecializedType); } - var exportedContainer = lhsType.getExportAssignedContainerSymbol(); - if (exportedContainer) { - var exportedContainerMembers = exportedContainer.getAllMembers(declSearchKind, memberVisibilty); - members = members.concat(exportedContainerMembers); - } - } else if (!lhsType.isConstructor()) { - var associatedContainerSymbol = lhsType.getAssociatedContainerType(); - if (associatedContainerSymbol) { - var containerType = associatedContainerSymbol.type; - this.resolveDeclaredSymbol(containerType, context); - var containerMembers = containerType.getAllMembers(declSearchKind, memberVisibilty); - members = members.concat(containerMembers); - } + lhsType = potentiallySpecializedType; } } - if ((lhsType.getCallSignatures().length || lhsType.getConstructSignatures().length) && this.cachedFunctionInterfaceType()) { + members = lhsType.getAllMembers(declSearchKind, memberVisibilty); + + if (lhsType.isContainer()) { + var associatedInstance = lhsType.getInstanceSymbol(); + if (associatedInstance) { + var instanceType = associatedInstance.type; + this.resolveDeclaredSymbol(instanceType, context); + var instanceMembers = instanceType.getAllMembers(declSearchKind, memberVisibilty); + members = members.concat(instanceMembers); + } + + var exportedContainer = lhsType.getExportAssignedContainerSymbol(); + if (exportedContainer) { + var exportedContainerMembers = exportedContainer.getAllMembers(declSearchKind, memberVisibilty); + members = members.concat(exportedContainerMembers); + } + } else if (!lhsType.isConstructor() && !lhsType.isEnum()) { + var associatedContainerSymbol = lhsType.getAssociatedContainerType(); + if (associatedContainerSymbol) { + var containerType = associatedContainerSymbol.type; + this.resolveDeclaredSymbol(containerType, context); + var containerMembers = containerType.getAllMembers(declSearchKind, memberVisibilty); + members = members.concat(containerMembers); + } + } + + if (lhsType.isFunctionType() && this.cachedFunctionInterfaceType()) { members = members.concat(this.cachedFunctionInterfaceType().getAllMembers(declSearchKind, 2 /* externallyVisible */)); } @@ -39456,22 +40285,26 @@ var TypeScript; return symbol; } - if (ast.kind() === 11 /* IdentifierName */ && ast.parent && ast.parent.kind() === 236 /* CatchClause */) { + if (ast.parent && ast.parent.kind() === 236 /* CatchClause */ && ast.parent.identifier === ast) { return symbol; } - var enclosingModule = TypeScript.getEnclosingModuleDeclaration(ast); + if (ast.parent && ast.parent.kind() === 219 /* SimpleArrowFunctionExpression */ && ast.parent.identifier === ast) { + return symbol; + } + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(ast); var resolvedSymbol; - if (TypeScript.isAnyNameOfModule(enclosingModule, ast)) { + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, ast)) { resolvedSymbol = this.resolveSingleModuleDeclaration(enclosingModule, ast, context); } else if (ast.kind() === 120 /* SourceUnit */ && decl.kind === 32 /* DynamicModule */) { resolvedSymbol = this.resolveModuleSymbol(decl.getSymbol(), context, null, null, ast); } else { - TypeScript.Debug.assert(ast.kind() != 11 /* IdentifierName */ && ast.kind() != 212 /* MemberAccessExpression */); - var resolvedSymbol = this.resolveAST(ast, false, context); + TypeScript.Debug.assert(ast.kind() !== 11 /* IdentifierName */ && ast.kind() !== 212 /* MemberAccessExpression */); + resolvedSymbol = this.resolveAST(ast, false, context); } - if (decl.kind == 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.anyDeclHasFlag(8388608 /* PropertyParameter */ | 67108864 /* ConstructorParameter */)) { + if (decl.kind === 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.anyDeclHasFlag(8388608 /* PropertyParameter */ | 67108864 /* ConstructorParameter */)) { symbol.type = resolvedSymbol.type; symbol.setResolved(); } @@ -39480,23 +40313,25 @@ var TypeScript; return symbol; }; + PullTypeResolver.prototype.resolveOtherDecl = function (otherDecl, context) { + var astForOtherDecl = this.getASTForDecl(otherDecl); + var moduleDecl = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(astForOtherDecl); + if (TypeScript.ASTHelpers.isAnyNameOfModule(moduleDecl, astForOtherDecl)) { + this.resolveSingleModuleDeclaration(moduleDecl, astForOtherDecl, context); + } else { + this.resolveAST(astForOtherDecl, false, context); + } + }; + PullTypeResolver.prototype.resolveOtherDeclarations = function (astName, context) { + var _this = this; var resolvedDecl = this.semanticInfoChain.getDeclForAST(astName); var symbol = resolvedDecl.getSymbol(); var allDecls = symbol.getDeclarations(); - for (var i = 0; i < allDecls.length; i++) { - var currentDecl = allDecls[i]; - var astForCurrentDecl = this.getASTForDecl(currentDecl); - if (astForCurrentDecl != astName) { - var moduleDecl = TypeScript.getEnclosingModuleDeclaration(astForCurrentDecl); - if (TypeScript.isAnyNameOfModule(moduleDecl, astForCurrentDecl)) { - this.resolveSingleModuleDeclaration(moduleDecl, astForCurrentDecl, context); - } else { - this.resolveAST(astForCurrentDecl, false, context); - } - } - } + this.inResolvingOtherDeclsWalker.walkOtherPullDecls(resolvedDecl, symbol.getDeclarations(), function (otherDecl) { + return _this.resolveOtherDecl(otherDecl, context); + }); }; PullTypeResolver.prototype.resolveSourceUnit = function (sourceUnit, context) { @@ -39515,9 +40350,26 @@ var TypeScript; }; PullTypeResolver.prototype.typeCheckSourceUnit = function (sourceUnit, context) { + var _this = this; this.setTypeChecked(sourceUnit, context); this.resolveAST(sourceUnit.moduleElements, false, context); + + this.typeCheckCallBacks.push(function (context) { + return _this.verifyUniquenessOfImportNamesInSourceUnit(sourceUnit); + }); + }; + + PullTypeResolver.prototype.verifyUniquenessOfImportNamesInSourceUnit = function (sourceUnit) { + var _this = this; + var enclosingDecl = this.semanticInfoChain.getDeclForAST(sourceUnit); + + var doesImportNameExistInOtherFiles = function (name) { + var importSymbol = _this.semanticInfoChain.findTopLevelSymbol(name, 128 /* TypeAlias */, null); + return importSymbol && importSymbol.isAlias(); + }; + + this.checkUniquenessOfImportNames([enclosingDecl], doesImportNameExistInOtherFiles); }; PullTypeResolver.prototype.resolveEnumDeclaration = function (ast, context) { @@ -39552,13 +40404,18 @@ var TypeScript; }; PullTypeResolver.prototype.typeCheckEnumDeclaration = function (ast, context) { + var _this = this; this.setTypeChecked(ast, context); this.resolveAST(ast.enumElements, false, context); var containerDecl = this.semanticInfoChain.getDeclForAST(ast); this.validateVariableDeclarationGroups(containerDecl, context); - if (!TypeScript.enumIsElided(ast)) { + this.typeCheckCallBacks.push(function (context) { + return _this.checkInitializersInEnumDeclarations(containerDecl, context); + }); + + if (!TypeScript.ASTHelpers.enumIsElided(ast)) { this.checkNameForCompilerGeneratedDeclarationCollision(ast, true, ast.identifier, context); } }; @@ -39567,6 +40424,34 @@ var TypeScript; this.checkThisCaptureVariableCollides(ast, true, context); }; + PullTypeResolver.prototype.checkInitializersInEnumDeclarations = function (decl, context) { + var symbol = decl.getSymbol(); + + var declarations = symbol.getDeclarations(); + if (decl !== declarations[0]) { + return; + } + + var seenEnumDeclWithNoFirstMember = false; + for (var i = 0; i < declarations.length; ++i) { + var currentDecl = declarations[i]; + + var ast = currentDecl.ast(); + if (ast.enumElements.nonSeparatorCount() === 0) { + continue; + } + + var firstVariable = ast.enumElements.nonSeparatorAt(0); + if (!firstVariable.equalsValueClause) { + if (!seenEnumDeclWithNoFirstMember) { + seenEnumDeclWithNoFirstMember = true; + } else { + this.semanticInfoChain.addDiagnosticFromAST(firstVariable, TypeScript.DiagnosticCode.In_enums_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_the_first_enum_element); + } + } + } + }; + PullTypeResolver.prototype.resolveModuleDeclaration = function (ast, context) { var result; @@ -39614,7 +40499,7 @@ var TypeScript; this.resolveDeclaredSymbol(instanceSymbol, context); } - var isLastName = TypeScript.isLastNameOfModule(moduleDeclAST, moduleDeclNameAST); + var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDeclAST, moduleDeclNameAST); if (isLastName) { this.resolveFirstExportAssignmentStatement(moduleDeclAST.moduleElements, context); } else if (sourceUnitAST) { @@ -39633,7 +40518,7 @@ var TypeScript; PullTypeResolver.prototype.resolveFirstExportAssignmentStatement = function (moduleElements, context) { for (var i = 0, n = moduleElements.childCount(); i < n; i++) { var moduleElement = moduleElements.childAt(i); - if (moduleElement.kind() == 134 /* ExportAssignment */) { + if (moduleElement.kind() === 134 /* ExportAssignment */) { this.resolveExportAssignmentStatement(moduleElement, context); return; } @@ -39659,9 +40544,10 @@ var TypeScript; }; PullTypeResolver.prototype.typeCheckSingleModuleDeclaration = function (ast, astName, context) { + var _this = this; this.setTypeChecked(ast, context); - if (TypeScript.isLastNameOfModule(ast, astName)) { + if (TypeScript.ASTHelpers.isLastNameOfModule(ast, astName)) { this.resolveAST(ast.moduleElements, false, context); } @@ -39674,9 +40560,106 @@ var TypeScript; } } - if (!TypeScript.moduleIsElided(ast) && !ast.stringLiteral) { + if (!TypeScript.ASTHelpers.moduleIsElided(ast) && !ast.stringLiteral) { this.checkNameForCompilerGeneratedDeclarationCollision(astName, true, astName, context); } + + this.typeCheckCallBacks.push(function (context) { + return _this.verifyUniquenessOfImportNamesInModule(containerDecl); + }); + }; + + PullTypeResolver.prototype.verifyUniquenessOfImportNamesInModule = function (decl) { + var symbol = decl.getSymbol(); + if (!symbol) { + return; + } + + var decls = symbol.getDeclarations(); + + if (decls[0] !== decl) { + return; + } + + this.checkUniquenessOfImportNames(decls); + }; + + PullTypeResolver.prototype.checkUniquenessOfImportNames = function (decls, doesNameExistOutside) { + var _this = this; + var importDeclarationNames; + + for (var i = 0; i < decls.length; ++i) { + var childDecls = decls[i].getChildDecls(); + for (var j = 0; j < childDecls.length; ++j) { + var childDecl = childDecls[j]; + if (childDecl.kind === 128 /* TypeAlias */) { + importDeclarationNames = importDeclarationNames || TypeScript.createIntrinsicsObject(); + importDeclarationNames[childDecl.name] = true; + } + } + } + + if (!importDeclarationNames && !doesNameExistOutside) { + return; + } + + for (var i = 0; i < decls.length; ++i) { + this.scanVariableDeclarationGroups(decls[i], function (firstDeclInGroup) { + var nameConflict = importDeclarationNames && importDeclarationNames[firstDeclInGroup.name]; + if (!nameConflict) { + nameConflict = doesNameExistOutside && doesNameExistOutside(firstDeclInGroup.name); + if (nameConflict) { + importDeclarationNames = importDeclarationNames || TypeScript.createIntrinsicsObject(); + importDeclarationNames[firstDeclInGroup.name] = true; + } + } + + if (nameConflict) { + _this.semanticInfoChain.addDiagnosticFromAST(firstDeclInGroup.ast(), TypeScript.DiagnosticCode.Variable_declaration_cannot_have_the_same_name_as_an_import_declaration); + } + }); + } + }; + + PullTypeResolver.prototype.scanVariableDeclarationGroups = function (enclosingDecl, firstDeclHandler, subsequentDeclHandler) { + var declGroups = enclosingDecl.getVariableDeclGroups(); + + for (var i = 0; i < declGroups.length; i++) { + var firstSymbol = null; + var enclosingDeclForFirstSymbol = null; + + if (enclosingDecl.kind === 1 /* Script */ && declGroups[i].length) { + var name = declGroups[i][0].name; + var candidateSymbol = this.semanticInfoChain.findTopLevelSymbol(name, 512 /* Variable */, enclosingDecl); + if (candidateSymbol && candidateSymbol.isResolved) { + if (!candidateSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */)) { + firstSymbol = candidateSymbol; + } + } + } + + for (var j = 0; j < declGroups[i].length; j++) { + var decl = declGroups[i][j]; + + var name = decl.name; + + var symbol = decl.getSymbol(); + + if (j === 0) { + firstDeclHandler(decl); + if (!subsequentDeclHandler) { + break; + } + + if (!firstSymbol || !firstSymbol.type) { + firstSymbol = symbol; + continue; + } + } + + subsequentDeclHandler(decl, firstSymbol); + } + } }; PullTypeResolver.prototype.postTypeCheckModuleDeclaration = function (ast, context) { @@ -39684,12 +40667,12 @@ var TypeScript; }; PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (term) { - if (term.kind() == 11 /* IdentifierName */) { + if (term.kind() === 11 /* IdentifierName */) { return true; - } else if (term.kind() == 121 /* QualifiedName */) { + } else if (term.kind() === 121 /* QualifiedName */) { var binex = term; - if (binex.right.kind() == 11 /* IdentifierName */) { + if (binex.right.kind() === 11 /* IdentifierName */) { return true; } } @@ -39719,7 +40702,7 @@ var TypeScript; var enclosingDecl = this.getEnclosingDecl(typeDecl); var typeDeclSymbol = typeDecl.getSymbol(); var typeDeclIsClass = classOrInterface.kind() === 131 /* ClassDeclaration */; - var hasVisited = this.getSymbolForAST(classOrInterface, context) != null; + var hasVisited = this.getSymbolForAST(classOrInterface, context) !== null; if ((typeDeclSymbol.isResolved && hasVisited) || (typeDeclSymbol.inResolution && !context.isInBaseTypeResolution())) { return typeDeclSymbol; @@ -39728,13 +40711,6 @@ var TypeScript; var wasResolving = typeDeclSymbol.inResolution; typeDeclSymbol.startResolving(); - if (!typeDeclSymbol.isResolved) { - var typeDeclTypeParameters = typeDeclSymbol.getTypeParameters(); - for (var i = 0; i < typeDeclTypeParameters.length; i++) { - this.resolveDeclaredSymbol(typeDeclTypeParameters[i], context); - } - } - var typeRefDecls = typeDeclSymbol.getDeclarations(); for (var i = 0; i < typeRefDecls.length; i++) { @@ -39745,13 +40721,20 @@ var TypeScript; } } + if (!typeDeclSymbol.isResolved) { + var typeDeclTypeParameters = typeDeclSymbol.getTypeParameters(); + for (var i = 0; i < typeDeclTypeParameters.length; i++) { + this.resolveDeclaredSymbol(typeDeclTypeParameters[i], context); + } + } + var wasInBaseTypeResolution = context.startBaseTypeResolution(); if (!typeDeclIsClass && !hasVisited) { typeDeclSymbol.resetKnownBaseTypeCount(); } - var extendsClause = TypeScript.getExtendsHeritageClause(heritageClauses); + var extendsClause = TypeScript.ASTHelpers.getExtendsHeritageClause(heritageClauses); if (extendsClause) { for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < extendsClause.typeNames.nonSeparatorCount(); i = typeDeclSymbol.getKnownBaseTypeCount()) { typeDeclSymbol.incrementKnownBaseCount(); @@ -39775,7 +40758,7 @@ var TypeScript; } } - var implementsClause = TypeScript.getImplementsHeritageClause(heritageClauses); + var implementsClause = TypeScript.ASTHelpers.getImplementsHeritageClause(heritageClauses); if (implementsClause && typeDeclIsClass) { var extendsCount = extendsClause ? extendsClause.typeNames.nonSeparatorCount() : 0; for (var i = typeDeclSymbol.getKnownBaseTypeCount(); ((i - extendsCount) >= 0) && ((i - extendsCount) < implementsClause.typeNames.nonSeparatorCount()); i = typeDeclSymbol.getKnownBaseTypeCount()) { @@ -39801,7 +40784,7 @@ var TypeScript; typeDeclSymbol.inResolution = false; this.typeCheckCallBacks.push(function (context) { - if (classOrInterface.kind() == 131 /* ClassDeclaration */) { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { _this.resolveClassDeclaration(classOrInterface, context); } else { _this.resolveInterfaceDeclaration(classOrInterface, context); @@ -39811,25 +40794,6 @@ var TypeScript; return typeDeclSymbol; } - if (!typeDeclSymbol.isResolved) { - if (!typeDeclIsClass) { - var callSignatures = typeDeclSymbol.getCallSignatures(); - for (var i = 0; i < callSignatures.length; i++) { - this.resolveDeclaredSymbol(callSignatures[i], context); - } - - var constructSignatures = typeDeclSymbol.getConstructSignatures(); - for (var i = 0; i < constructSignatures.length; i++) { - this.resolveDeclaredSymbol(constructSignatures[i], context); - } - - var indexSignatures = typeDeclSymbol.getIndexSignatures(); - for (var i = 0; i < indexSignatures.length; i++) { - this.resolveDeclaredSymbol(indexSignatures[i], context); - } - } - } - this.setSymbolForAST(name, typeDeclSymbol, context); this.setSymbolForAST(classOrInterface, typeDeclSymbol, context); @@ -39841,6 +40805,7 @@ var TypeScript; PullTypeResolver.prototype.resolveClassDeclaration = function (classDeclAST, context) { var classDecl = this.semanticInfoChain.getDeclForAST(classDeclAST); var classDeclSymbol = classDecl.getSymbol(); + if (!classDeclSymbol.isResolved) { this.resolveReferenceTypeDeclaration(classDeclAST, classDeclAST.identifier, classDeclAST.heritageClauses, context); @@ -39869,15 +40834,9 @@ var TypeScript; if (!parentConstructSignatures.length) { parentConstructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); parentConstructSignature.returnType = parentType; - parentConstructorType.addConstructSignature(parentConstructSignature); + parentConstructSignature.addTypeParametersFromReturnType(); + parentConstructorType.appendConstructSignature(parentConstructSignature); parentConstructSignature.addDeclaration(parentType.getDeclarations()[0]); - - var parentTypeParameters = parentConstructorType.getTypeParameters(); - - for (var i = 0; i < parentTypeParameters.length; i++) { - parentConstructSignature.addTypeParameter(parentTypeParameters[i]); - } - parentConstructSignatures = [parentConstructSignature]; } @@ -39885,33 +40844,23 @@ var TypeScript; parentConstructSignature = parentConstructSignatures[i]; parentParameters = parentConstructSignature.parameters; - constructorSignature = parentConstructSignature.isDefinition() ? new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */) : new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */, parentConstructSignature.isDefinition()); constructorSignature.returnType = classDeclSymbol; + constructorSignature.addTypeParametersFromReturnType(); for (var j = 0; j < parentParameters.length; j++) { constructorSignature.addParameter(parentParameters[j], parentParameters[j].isOptional); } - var typeParameters = constructorTypeSymbol.getTypeParameters(); - - for (var j = 0; j < typeParameters.length; j++) { - constructorSignature.addTypeParameter(typeParameters[j]); - } - - constructorTypeSymbol.addConstructSignature(constructorSignature); + constructorTypeSymbol.appendConstructSignature(constructorSignature); constructorSignature.addDeclaration(classDecl); } } else { constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); constructorSignature.returnType = classDeclSymbol; - constructorTypeSymbol.addConstructSignature(constructorSignature); + constructorSignature.addTypeParametersFromReturnType(); + constructorTypeSymbol.appendConstructSignature(constructorSignature); constructorSignature.addDeclaration(classDecl); - - var typeParameters = constructorTypeSymbol.getTypeParameters(); - - for (var i = 0; i < typeParameters.length; i++) { - constructorSignature.addTypeParameter(typeParameters[i]); - } } } @@ -39944,13 +40893,23 @@ var TypeScript; PullTypeResolver.prototype.typeCheckTypeParametersOfTypeDeclaration = function (classOrInterface, context) { var _this = this; - var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); - var typeDeclSymbol = typeDecl.getSymbol(); - var typeDeclTypeParameters = typeDeclSymbol.getTypeParameters(); - for (var i = 0; i < typeDeclTypeParameters.length; i++) { - this.checkSymbolPrivacy(typeDeclSymbol, typeDeclTypeParameters[i], function (symbol) { - return _this.typeParameterOfTypeDeclarationPrivacyErrorReporter(classOrInterface, i, typeDeclTypeParameters[i], symbol, context); - }); + var typeParametersList = classOrInterface.kind() == 131 /* ClassDeclaration */ ? classOrInterface.typeParameterList : classOrInterface.typeParameterList; + + if (typeParametersList) { + var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); + var typeDeclSymbol = typeDecl.getSymbol(); + + for (var i = 0; i < typeParametersList.typeParameters.nonSeparatorCount(); i++) { + var typeParameterAST = typeParametersList.typeParameters.nonSeparatorAt(i); + this.resolveTypeParameterDeclaration(typeParameterAST, context); + + var typeParameterDecl = this.semanticInfoChain.getDeclForAST(typeParameterAST); + var typeParameterSymbol = typeParameterDecl.getSymbol(); + + this.checkSymbolPrivacy(typeDeclSymbol, typeParameterSymbol, function (symbol) { + return _this.typeParameterOfTypeDeclarationPrivacyErrorReporter(classOrInterface, typeParameterAST, typeParameterSymbol, symbol, context); + }); + } } }; @@ -39969,6 +40928,8 @@ var TypeScript; if (!classDeclSymbol.hasBaseTypeConflict()) { this.typeCheckMembersAgainstIndexer(classDeclSymbol, classDecl, context); } + + this.checkTypeForDuplicateIndexSignatures(classDeclSymbol); }; PullTypeResolver.prototype.postTypeCheckClassDeclaration = function (classDeclAST, context) { @@ -40025,6 +40986,88 @@ var TypeScript; if (!interfaceDeclSymbol.hasBaseTypeConflict()) { this.typeCheckMembersAgainstIndexer(interfaceDeclSymbol, interfaceDecl, context); } + + var allInterfaceDecls = interfaceDeclSymbol.getDeclarations(); + if (interfaceDecl === allInterfaceDecls[allInterfaceDecls.length - 1]) { + this.checkTypeForDuplicateIndexSignatures(interfaceDeclSymbol); + } + + if (!this.checkInterfaceDeclForIdenticalTypeParameters(interfaceDeclAST, context)) { + this.semanticInfoChain.addDiagnosticFromAST(interfaceDeclAST.identifier, TypeScript.DiagnosticCode.All_declarations_of_an_interface_must_have_identical_type_parameters); + } + }; + + PullTypeResolver.prototype.checkInterfaceDeclForIdenticalTypeParameters = function (interfaceDeclAST, context) { + var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); + var interfaceDeclSymbol = interfaceDecl.getSymbol(); + + if (!interfaceDeclSymbol.isGeneric()) { + return true; + } + + var firstInterfaceDecl = interfaceDeclSymbol.getDeclarations()[0]; + if (firstInterfaceDecl == interfaceDecl) { + return true; + } + + var typeParameters = interfaceDecl.getTypeParameters(); + var firstInterfaceDeclTypeParameters = firstInterfaceDecl.getTypeParameters(); + + if (typeParameters.length != firstInterfaceDeclTypeParameters.length) { + return false; + } + + for (var i = 0; i < typeParameters.length; i++) { + var typeParameter = typeParameters[i]; + var firstInterfaceDeclTypeParameter = firstInterfaceDeclTypeParameters[i]; + + if (typeParameter.name != firstInterfaceDeclTypeParameter.name) { + return false; + } + + var typeParameterSymbol = typeParameter.getSymbol(); + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter); + var firstInterfaceDeclTypeParameterAST = this.semanticInfoChain.getASTForDecl(firstInterfaceDeclTypeParameter); + + if (!!typeParameterAST.constraint != !!firstInterfaceDeclTypeParameterAST.constraint) { + return false; + } + + if (typeParameterAST.constraint) { + var typeParameterConstraint = this.resolveAST(typeParameterAST.constraint, false, context); + if (!this.typesAreIdenticalWithNewEnclosingTypes(typeParameterConstraint, typeParameterSymbol.getConstraint(), context)) { + return false; + } + } + } + + return true; + }; + + PullTypeResolver.prototype.checkTypeForDuplicateIndexSignatures = function (enclosingTypeSymbol) { + var indexSignatures = enclosingTypeSymbol.getOwnIndexSignatures(); + var firstStringIndexer = null; + var firstNumberIndexer = null; + for (var i = 0; i < indexSignatures.length; i++) { + var currentIndexer = indexSignatures[i]; + var currentParameterType = currentIndexer.parameters[0].type; + TypeScript.Debug.assert(currentParameterType); + if (currentParameterType === this.semanticInfoChain.stringTypeSymbol) { + if (firstStringIndexer) { + this.semanticInfoChain.addDiagnosticFromAST(currentIndexer.getDeclarations()[0].ast(), TypeScript.DiagnosticCode.Duplicate_string_index_signature, null, [this.semanticInfoChain.locationFromAST(firstStringIndexer.getDeclarations()[0].ast())]); + return; + } else { + firstStringIndexer = currentIndexer; + } + } else if (currentParameterType === this.semanticInfoChain.numberTypeSymbol) { + if (firstNumberIndexer) { + this.semanticInfoChain.addDiagnosticFromAST(currentIndexer.getDeclarations()[0].ast(), TypeScript.DiagnosticCode.Duplicate_number_index_signature, null, [this.semanticInfoChain.locationFromAST(firstNumberIndexer.getDeclarations()[0].ast())]); + return; + } else { + firstNumberIndexer = currentIndexer; + } + } + } }; PullTypeResolver.prototype.filterSymbol = function (symbol, kind, enclosingDecl, context) { @@ -40039,7 +41082,7 @@ var TypeScript; var alias = symbol; if (kind & 164 /* SomeContainer */) { return alias.getExportAssignedContainerSymbol(); - } else if (kind & 58728539 /* SomeType */) { + } else if (kind & 58728795 /* SomeType */) { return alias.getExportAssignedTypeSymbol(); } else if (kind & 68147712 /* SomeValue */) { return alias.getExportAssignedValueSymbol(); @@ -40050,7 +41093,7 @@ var TypeScript; }; PullTypeResolver.prototype.getMemberSymbolOfKind = function (symbolName, kind, pullTypeSymbol, enclosingDecl, context) { - var memberSymbol = this.getMemberSymbol(symbolName, kind, pullTypeSymbol); + var memberSymbol = this.getNamedPropertySymbol(symbolName, kind, pullTypeSymbol); return { symbol: this.filterSymbol(memberSymbol, kind, enclosingDecl, context), @@ -40074,11 +41117,11 @@ var TypeScript; var acceptableAlias = true; if (containerSymbol) { - acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) != 0; + acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; aliasSymbol = memberSymbol.aliasSymbol; } - if (!acceptableAlias && containerSymbol && containerSymbol.kind == 128 /* TypeAlias */) { + if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { this.resolveDeclaredSymbol(containerSymbol, context); var aliasedAssignedValue = containerSymbol.getExportAssignedValueSymbol(); var aliasedAssignedType = containerSymbol.getExportAssignedTypeSymbol(); @@ -40109,7 +41152,7 @@ var TypeScript; } if (!typeSymbol) { - memberSymbol = this.getMemberSymbolOfKind(rhsName, 58728539 /* SomeType */, moduleTypeSymbol, enclosingDecl, context); + memberSymbol = this.getMemberSymbolOfKind(rhsName, 58728795 /* SomeType */, moduleTypeSymbol, enclosingDecl, context); typeSymbol = memberSymbol.symbol; if (typeSymbol && memberSymbol.aliasSymbol) { aliasSymbol = memberSymbol.aliasSymbol; @@ -40134,12 +41177,12 @@ var TypeScript; }; PullTypeResolver.prototype.resolveModuleReference = function (importDecl, moduleNameExpr, enclosingDecl, context, declPath) { - TypeScript.Debug.assert(moduleNameExpr.kind() == 121 /* QualifiedName */ || moduleNameExpr.kind() == 11 /* IdentifierName */ || moduleNameExpr.kind() === 14 /* StringLiteral */, "resolving module reference should always be either name or member reference"); + TypeScript.Debug.assert(moduleNameExpr.kind() === 121 /* QualifiedName */ || moduleNameExpr.kind() === 11 /* IdentifierName */ || moduleNameExpr.kind() === 14 /* StringLiteral */, "resolving module reference should always be either name or member reference"); var moduleSymbol = null; var moduleName; - if (moduleNameExpr.kind() == 121 /* QualifiedName */) { + if (moduleNameExpr.kind() === 121 /* QualifiedName */) { var dottedNameAST = moduleNameExpr; var moduleContainer = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); if (moduleContainer) { @@ -40161,6 +41204,8 @@ var TypeScript; this.semanticInfoChain.setSymbolForAST(moduleNameExpr, moduleSymbol); if (resolvedModuleNameSymbol.isAlias()) { this.semanticInfoChain.setAliasSymbolForAST(moduleNameExpr, resolvedModuleNameSymbol); + var importDeclSymbol = importDecl.getSymbol(); + importDeclSymbol.addLinkedAliasSymbol(resolvedModuleNameSymbol); } } else { this.semanticInfoChain.addDiagnosticFromAST(moduleNameExpr, TypeScript.DiagnosticCode.Unable_to_resolve_module_reference_0, [valueText]); @@ -40181,6 +41226,7 @@ var TypeScript; var declPath = enclosingDecl.getParentPath(); var aliasedType = null; + var importDeclSymbol = importDecl.getSymbol(); if (aliasExpr.kind() === 11 /* IdentifierName */ || aliasExpr.kind() === 14 /* StringLiteral */) { var moduleSymbol = this.resolveModuleReference(importDecl, aliasExpr, enclosingDecl, context, declPath); @@ -40192,19 +41238,17 @@ var TypeScript; var valueSymbol = this.getSymbolFromDeclPath(moduleName, declPath, 68147712 /* SomeValue */); var instanceSymbol = aliasedType.getInstanceSymbol(); - if (valueSymbol && (instanceSymbol != valueSymbol || valueSymbol.type == aliasedType)) { + if (valueSymbol && (instanceSymbol != valueSymbol || valueSymbol.type === aliasedType)) { var text = aliasExpr.kind() === 11 /* IdentifierName */ ? aliasExpr.text() : aliasExpr.text(); context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(aliasExpr, TypeScript.DiagnosticCode.Internal_module_reference_0_in_import_declaration_does_not_reference_module_instance_for_1, [text, moduleSymbol.type.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); } else { - var importDeclSymbol = importDecl.getSymbol(); importDeclSymbol.setAssignedValueSymbol(valueSymbol); } } } else { - aliasedType = this.semanticInfoChain.anyTypeSymbol; + aliasedType = this.getNewErrorTypeSymbol(); } - } else if (aliasExpr.kind() == 121 /* QualifiedName */) { - var importDeclSymbol = importDecl.getSymbol(); + } else if (aliasExpr.kind() === 121 /* QualifiedName */) { var dottedNameAST = aliasExpr; var moduleSymbol = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); if (moduleSymbol) { @@ -40214,14 +41258,13 @@ var TypeScript; importDeclSymbol.setAssignedTypeSymbol(identifierResolution.typeSymbol); importDeclSymbol.setAssignedContainerSymbol(identifierResolution.containerSymbol); this.semanticInfoChain.setAliasSymbolForAST(moduleReference, identifierResolution.aliasSymbol); - if (identifierResolution.valueSymbol) { - importDeclSymbol.setIsUsedAsValue(true); - } return null; } } + } - importDeclSymbol.setAssignedTypeSymbol(this.semanticInfoChain.anyTypeSymbol); + if (!aliasedType) { + importDeclSymbol.setAssignedTypeSymbol(this.getNewErrorTypeSymbol()); } return aliasedType; @@ -40249,7 +41292,7 @@ var TypeScript; if (!aliasedType) { var path = importStatementAST.moduleReference.stringLiteral.text(); this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Unable_to_resolve_external_module_0, [path]); - aliasedType = this.semanticInfoChain.anyTypeSymbol; + aliasedType = this.getNewErrorTypeSymbol(); } } else { aliasedType = this.resolveInternalModuleReference(importStatementAST, context); @@ -40258,9 +41301,9 @@ var TypeScript; if (aliasedType) { if (!aliasedType.isContainer()) { this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Module_cannot_be_aliased_to_a_non_module_type); - aliasedType = this.semanticInfoChain.anyTypeSymbol; - } else if (aliasedType.getExportAssignedValueSymbol()) { - importDeclSymbol.setIsUsedAsValue(true); + if (!aliasedType.isError()) { + aliasedType = this.getNewErrorTypeSymbol(); + } } if (aliasedType.isContainer()) { @@ -40277,6 +41320,14 @@ var TypeScript; this.resolveDeclaredSymbol(importDeclSymbol.assignedType(), context); this.resolveDeclaredSymbol(importDeclSymbol.assignedContainer(), context); + if (aliasedType && importDeclSymbol.anyDeclHasFlag(1 /* Exported */)) { + importDeclSymbol.setIsUsedInExportedAlias(); + + if (aliasedType.isContainer() && aliasedType.getExportAssignedValueSymbol()) { + importDeclSymbol.setIsUsedAsValue(); + } + } + if (this.canTypeCheckAST(importStatementAST, context)) { this.typeCheckImportDeclaration(importStatementAST, context); } @@ -40299,7 +41350,7 @@ var TypeScript; var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); if (enclosingDecl.kind === 32 /* DynamicModule */) { - var ast = TypeScript.getEnclosingModuleDeclaration(this.getASTForDecl(enclosingDecl)); + var ast = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(this.getASTForDecl(enclosingDecl)); if (ast && ast.kind() === 130 /* ModuleDeclaration */) { if (TypeScript.isRelative(modPath)) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name)); @@ -40312,7 +41363,7 @@ var TypeScript; if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); var container = containerSymbol ? containerSymbol.getContainer() : null; - if (container && container.kind == 32 /* DynamicModule */) { + if (container && container.kind === 32 /* DynamicModule */) { checkPrivacy = true; } } else { @@ -40330,7 +41381,7 @@ var TypeScript; context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); }); - if (typeSymbol != containerSymbol) { + if (typeSymbol !== containerSymbol) { this.checkSymbolPrivacy(importDeclSymbol, typeSymbol, function (symbol) { var messageCode = symbol.isContainer() && !symbol.isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_type_that_has_or_is_using_private_type_1; @@ -40348,14 +41399,18 @@ var TypeScript; } } - if (getCompilerReservedName(importStatementAST.identifier)) { - this.postTypeCheckWorkitems.push(importStatementAST); - } + this.checkNameForCompilerGeneratedDeclarationCollision(importStatementAST, true, importStatementAST.identifier, context); }; PullTypeResolver.prototype.postTypeCheckImportDeclaration = function (importStatementAST, context) { - if (TypeScript.importDeclarationIsElided(importStatementAST, this.semanticInfoChain)) { - this.checkNameForCompilerGeneratedDeclarationCollision(importStatementAST, true, importStatementAST.identifier, context, true); + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var importSymbol = importDecl.getSymbol(); + + var isUsedAsValue = importSymbol.isUsedAsValue(); + var hasAssignedValue = importStatementAST.moduleReference.kind() !== 245 /* ExternalModuleReference */ && importSymbol.getExportAssignedValueSymbol() !== null; + + if (isUsedAsValue || hasAssignedValue) { + this.checkThisCaptureVariableCollides(importStatementAST, true, context); } }; @@ -40384,10 +41439,10 @@ var TypeScript; var acceptableAlias = true; if (containerSymbol) { - acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) != 0; + acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; } - if (!acceptableAlias && containerSymbol && containerSymbol.kind == 128 /* TypeAlias */) { + if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { this.resolveDeclaredSymbol(containerSymbol, context); var aliasSymbol = containerSymbol; @@ -40399,7 +41454,10 @@ var TypeScript; valueSymbol = aliasedAssignedValue; typeSymbol = aliasedAssignedType; containerSymbol = aliasedAssignedContainer; - aliasSymbol.setTypeUsedExternally(true); + aliasSymbol.setTypeUsedExternally(); + if (valueSymbol) { + aliasSymbol.setIsUsedAsValue(); + } acceptableAlias = true; } } @@ -40413,7 +41471,7 @@ var TypeScript; valueSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); } if (!typeSymbol) { - typeSymbol = this.getSymbolFromDeclPath(id, declPath, 58728539 /* SomeType */); + typeSymbol = this.getSymbolFromDeclPath(id, declPath, 58728795 /* SomeType */); } if (!valueSymbol && !typeSymbol && !containerSymbol) { @@ -40477,28 +41535,32 @@ var TypeScript; var paramSymbol = paramDecl.getSymbol(); if (argDeclAST.typeAnnotation) { - var typeRef = this.resolveTypeReference(TypeScript.getType(argDeclAST), context); + var typeRef = this.resolveTypeReference(TypeScript.ASTHelpers.getType(argDeclAST), context); if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { - var diagnostic = context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); typeRef = this.getNewErrorTypeSymbol(); } context.setTypeInContext(paramSymbol, typeRef); } else { - if (paramSymbol.isVarArg && paramSymbol.type) { + if (paramSymbol.isVarArg) { if (this.cachedArrayInterfaceType()) { - context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [paramSymbol.type])); + context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); } else { - context.setTypeInContext(paramSymbol, paramSymbol.type); + context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); } } else { context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); - - if (this.compilationSettings.noImplicitAny()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_function_type_implicitly_has_an_any_type, [argDeclAST.identifier.text()])); - } } + + if (this.compilationSettings.noImplicitAny()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_function_type_implicitly_has_an_any_type, [argDeclAST.identifier.text()])); + } + } + + if (TypeScript.hasFlag(paramDecl.flags, 128 /* Optional */) && argDeclAST.equalsValueClause && isTypesOnlyLocation(argDeclAST)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Default_arguments_are_only_allowed_in_implementation)); } paramSymbol.setResolved(); @@ -40521,22 +41583,29 @@ var TypeScript; contextualType = typeRef || contextualType; } if (contextualType) { + if (context.isInferentiallyTyping()) { + contextualType = context.fixAllTypeParametersReferencedByType(contextualType, this); + } context.setTypeInContext(paramSymbol, contextualType); - } else if (paramSymbol.isVarArg && this.cachedArrayInterfaceType()) { - context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); + } else if (paramSymbol.isVarArg) { + if (this.cachedArrayInterfaceType()) { + context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); + } else { + context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); + } isImplicitAny = true; } var canTypeCheckAST = this.canTypeCheckAST(argDeclAST, context); if (equalsValueClause && (canTypeCheckAST || !contextualType)) { if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); + context.propagateContextualType(contextualType); } - var initExprSymbol = this.resolveAST(equalsValueClause, contextualType != null, context); + var initExprSymbol = this.resolveAST(equalsValueClause, contextualType !== null, context); if (contextualType) { - context.popContextualType(); + context.popAnyContextualType(); } if (!initExprSymbol || !initExprSymbol.type) { @@ -40548,7 +41617,7 @@ var TypeScript; } else { var initTypeSymbol = this.getInstanceTypeForAssignment(argDeclAST, initExprSymbol.type, context); if (!contextualType) { - context.setTypeInContext(paramSymbol, this.widenType(initTypeSymbol, equalsValueClause, context)); + context.setTypeInContext(paramSymbol, initTypeSymbol.widenedType(this, equalsValueClause, context)); isImplicitAny = initTypeSymbol !== paramSymbol.type; } else { var comparisonInfo = new TypeComparisonInfo(); @@ -40588,42 +41657,31 @@ var TypeScript; paramSymbol.setResolved(); }; - PullTypeResolver.prototype.checkNameForCompilerGeneratedDeclarationCollision = function (astWithName, isDeclaration, name, context, immediateThisCheck) { + PullTypeResolver.prototype.checkNameForCompilerGeneratedDeclarationCollision = function (astWithName, isDeclaration, name, context) { var compilerReservedName = getCompilerReservedName(name); - if (compilerReservedName) { - switch (compilerReservedName) { - case 1 /* _this */: - if (immediateThisCheck) { - this.checkThisCaptureVariableCollides(astWithName, isDeclaration, context); - } else { - this.postTypeCheckWorkitems.push(astWithName); - } - return; + switch (compilerReservedName) { + case 1 /* _this */: + this.postTypeCheckWorkitems.push(astWithName); + return; - case 2 /* _super */: - this.checkSuperCaptureVariableCollides(astWithName, isDeclaration, context); - return; + case 2 /* _super */: + this.checkSuperCaptureVariableCollides(astWithName, isDeclaration, context); + return; - case 3 /* arguments */: - this.checkArgumentsCollides(astWithName, context); - return; + case 3 /* arguments */: + this.checkArgumentsCollides(astWithName, context); + return; - case 4 /* _i */: - if (isDeclaration) { - this.checkIndexOfRestArgumentInitializationCollides(astWithName, context); - } - return; + case 4 /* _i */: + this.checkIndexOfRestArgumentInitializationCollides(astWithName, isDeclaration, context); + return; - case 5 /* require */: - case 6 /* exports */: - if (isDeclaration) { - this.checkExternalModuleRequireExportsCollides(astWithName, name, context); - } - return; - - default: - TypeScript.Debug.fail("Unknown compiler reserved name: " + name.text()); - } + case 5 /* require */: + case 6 /* exports */: + if (isDeclaration) { + this.checkExternalModuleRequireExportsCollides(astWithName, name, context); + } + return; } }; @@ -40631,16 +41689,16 @@ var TypeScript; var enclosingAST = this.getASTForDecl(someFunctionDecl); var nodeType = enclosingAST.kind(); - if (nodeType == 129 /* FunctionDeclaration */) { + if (nodeType === 129 /* FunctionDeclaration */) { var functionDeclaration = enclosingAST; - return !TypeScript.hasFlag(someFunctionDecl.kind == 65536 /* Method */ ? someFunctionDecl.getParentDecl().flags : someFunctionDecl.flags, 8 /* Ambient */) && functionDeclaration.block && TypeScript.lastParameterIsRest(functionDeclaration.callSignature.parameterList); + return !TypeScript.hasFlag(someFunctionDecl.kind === 65536 /* Method */ ? someFunctionDecl.getParentDecl().flags : someFunctionDecl.flags, 8 /* Ambient */) && functionDeclaration.block && TypeScript.lastParameterIsRest(functionDeclaration.callSignature.parameterList); } else if (nodeType === 135 /* MemberFunctionDeclaration */) { var memberFunction = enclosingAST; - return !TypeScript.hasFlag(someFunctionDecl.kind == 65536 /* Method */ ? someFunctionDecl.getParentDecl().flags : someFunctionDecl.flags, 8 /* Ambient */) && memberFunction.block && TypeScript.lastParameterIsRest(memberFunction.callSignature.parameterList); - } else if (nodeType == 137 /* ConstructorDeclaration */) { + return !TypeScript.hasFlag(someFunctionDecl.kind === 65536 /* Method */ ? someFunctionDecl.getParentDecl().flags : someFunctionDecl.flags, 8 /* Ambient */) && memberFunction.block && TypeScript.lastParameterIsRest(memberFunction.callSignature.parameterList); + } else if (nodeType === 137 /* ConstructorDeclaration */) { var constructorDeclaration = enclosingAST; - return !TypeScript.hasFlag(someFunctionDecl.getParentDecl().flags, 8 /* Ambient */) && constructorDeclaration.block && TypeScript.lastParameterIsRest(constructorDeclaration.parameterList); - } else if (nodeType == 218 /* ParenthesizedArrowFunctionExpression */) { + return !TypeScript.hasFlag(someFunctionDecl.getParentDecl().flags, 8 /* Ambient */) && constructorDeclaration.block && TypeScript.lastParameterIsRest(constructorDeclaration.callSignature.parameterList); + } else if (nodeType === 218 /* ParenthesizedArrowFunctionExpression */) { var arrowFunctionExpression = enclosingAST; return TypeScript.lastParameterIsRest(arrowFunctionExpression.callSignature.parameterList); } else if (nodeType === 222 /* FunctionExpression */) { @@ -40652,7 +41710,7 @@ var TypeScript; }; PullTypeResolver.prototype.checkArgumentsCollides = function (ast, context) { - if (ast.kind() == 242 /* Parameter */) { + if (ast.kind() === 242 /* Parameter */) { var enclosingDecl = this.getEnclosingDeclForAST(ast); if (TypeScript.hasFlag(enclosingDecl.kind, 1032192 /* SomeFunction */)) { if (this.hasRestParameterCodeGen(enclosingDecl)) { @@ -40662,12 +41720,33 @@ var TypeScript; } }; - PullTypeResolver.prototype.checkIndexOfRestArgumentInitializationCollides = function (ast, context) { - if (ast.kind() == 242 /* Parameter */) { + PullTypeResolver.prototype.checkIndexOfRestArgumentInitializationCollides = function (ast, isDeclaration, context) { + if (!isDeclaration || ast.kind() === 242 /* Parameter */) { var enclosingDecl = this.getEnclosingDeclForAST(ast); - if (TypeScript.hasFlag(enclosingDecl.kind, 1032192 /* SomeFunction */)) { - if (this.hasRestParameterCodeGen(enclosingDecl)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter)); + var declPath = isDeclaration ? [enclosingDecl] : (enclosingDecl ? enclosingDecl.getParentPath() : []); + var resolvedSymbol = null; + var resolvedSymbolContainer; + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + if (!isDeclaration) { + if (!resolvedSymbol) { + resolvedSymbol = this.resolveNameExpression(ast, context); + if (resolvedSymbol.isError()) { + return; + } + + resolvedSymbolContainer = resolvedSymbol.getContainer(); + } + + if (resolvedSymbolContainer && TypeScript.ArrayUtilities.contains(resolvedSymbolContainer.getDeclarations(), decl)) { + break; + } + } + + if (TypeScript.hasFlag(decl.kind, 1032192 /* SomeFunction */)) { + if (this.hasRestParameterCodeGen(decl)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter : TypeScript.DiagnosticCode.Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter)); + } } } } @@ -40676,12 +41755,12 @@ var TypeScript; PullTypeResolver.prototype.checkExternalModuleRequireExportsCollides = function (ast, name, context) { var enclosingDecl = this.getEnclosingDeclForAST(ast); - var enclosingModule = TypeScript.getEnclosingModuleDeclaration(name); - if (TypeScript.isAnyNameOfModule(enclosingModule, name)) { + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(name); + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, name)) { enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); } - if (enclosingDecl && enclosingDecl.kind == 32 /* DynamicModule */) { + if (enclosingDecl && enclosingDecl.kind === 32 /* DynamicModule */) { var decl = this.semanticInfoChain.getDeclForAST(ast); if (!TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { @@ -40733,6 +41812,7 @@ var TypeScript; var objectTypeSymbol = objectTypeDecl.getSymbol(); this.typeCheckMembersAgainstIndexer(objectTypeSymbol, objectTypeDecl, context); + this.checkTypeForDuplicateIndexSignatures(objectTypeSymbol); }; PullTypeResolver.prototype.resolveTypeAnnotation = function (typeAnnotation, context) { @@ -40749,11 +41829,11 @@ var TypeScript; var aliasType = null; var type = this.computeTypeReferenceSymbol(typeRef, context); - if (type.kind == 4 /* Container */) { + if (type.kind === 4 /* Container */) { var container = type; var instanceSymbol = container.getInstanceSymbol(); - if (instanceSymbol && (instanceSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind == 32768 /* ConstructorMethod */)) { + if (instanceSymbol && (instanceSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind === 32768 /* ConstructorMethod */)) { type = instanceSymbol.type.getAssociatedContainerType(); } } @@ -40770,7 +41850,7 @@ var TypeScript; } if (type && !type.isError()) { - if ((type.kind & 58728539 /* SomeType */) === 0) { + if ((type.kind & 58728795 /* SomeType */) === 0) { if (type.kind & 164 /* SomeContainer */) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeRef, TypeScript.DiagnosticCode.Type_reference_cannot_refer_to_container_0, [aliasType ? aliasType.toString() : type.toString()])); } else { @@ -40786,6 +41866,22 @@ var TypeScript; return type; }; + PullTypeResolver.prototype.getArrayType = function (elementType) { + var arraySymbol = elementType.getArrayType(); + + if (!arraySymbol) { + arraySymbol = this.createInstantiatedType(this.cachedArrayInterfaceType(), [elementType]); + + if (!arraySymbol) { + arraySymbol = this.semanticInfoChain.anyTypeSymbol; + } + + elementType.setArrayType(arraySymbol); + } + + return arraySymbol; + }; + PullTypeResolver.prototype.computeTypeReferenceSymbol = function (term, context) { switch (term.kind()) { case 60 /* AnyKeyword */: @@ -40820,7 +41916,7 @@ var TypeScript; var stringConstantAST = term; var enclosingDecl = this.getEnclosingDeclForAST(term); typeDeclSymbol = new TypeScript.PullStringConstantTypeSymbol(stringConstantAST.text()); - var decl = new TypeScript.PullSynthesizedDecl(stringConstantAST.text(), stringConstantAST.text(), typeDeclSymbol.kind, null, enclosingDecl, new TypeScript.TextSpan(stringConstantAST.start(), stringConstantAST.width()), enclosingDecl.semanticInfoChain()); + var decl = new TypeScript.PullSynthesizedDecl(stringConstantAST.text(), stringConstantAST.text(), typeDeclSymbol.kind, null, enclosingDecl, enclosingDecl.semanticInfoChain); typeDeclSymbol.addDeclaration(decl); } else if (term.kind() === 127 /* TypeQuery */) { var typeQuery = term; @@ -40839,24 +41935,14 @@ var TypeScript; } if (valueSymbol) { - typeDeclSymbol = valueSymbol.type; + typeDeclSymbol = valueSymbol.type.widenedType(this, typeQueryTerm, context); } else { typeDeclSymbol = this.getNewErrorTypeSymbol(); } } else if (term.kind() === 124 /* ArrayType */) { var arrayType = term; - var underlying = this.computeTypeReferenceSymbol(arrayType.type, context); - var arraySymbol = underlying.getArrayType(); - - if (!arraySymbol) { - arraySymbol = this.createInstantiatedType(this.cachedArrayInterfaceType(), [underlying]); - - if (!arraySymbol) { - arraySymbol = this.semanticInfoChain.anyTypeSymbol; - } - } - - typeDeclSymbol = arraySymbol; + var underlying = this.resolveTypeReference(arrayType.type, context); + typeDeclSymbol = this.getArrayType(underlying); } else { throw TypeScript.Errors.invalidOperation("unknown type"); } @@ -40879,19 +41965,27 @@ var TypeScript; }; PullTypeResolver.prototype.genericTypeIsUsedWithoutRequiredTypeArguments = function (typeSymbol, term, context) { - return typeSymbol.isNamedTypeSymbol() && typeSymbol.isGeneric() && !typeSymbol.isTypeParameter() && (typeSymbol.isResolved || typeSymbol.inResolution) && !typeSymbol.getIsSpecialized() && typeSymbol.getTypeParameters().length && typeSymbol.getTypeArguments() == null && this.isTypeRefWithoutTypeArgs(term); + if (!typeSymbol) { + return false; + } + + if (typeSymbol.isAlias()) { + return this.genericTypeIsUsedWithoutRequiredTypeArguments(typeSymbol.getExportAssignedTypeSymbol(), term, context); + } + + return typeSymbol.isNamedTypeSymbol() && typeSymbol.isGeneric() && !typeSymbol.isTypeParameter() && (typeSymbol.isResolved || typeSymbol.inResolution) && !typeSymbol.getIsSpecialized() && typeSymbol.getTypeParameters().length && typeSymbol.getTypeArguments() === null && this.isTypeRefWithoutTypeArgs(term); }; PullTypeResolver.prototype.resolveMemberVariableDeclaration = function (varDecl, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(varDecl, varDecl.modifiers, varDecl.variableDeclarator.propertyName, TypeScript.getType(varDecl.variableDeclarator), varDecl.variableDeclarator.equalsValueClause, context); + return this.resolveVariableDeclaratorOrParameterOrEnumElement(varDecl, varDecl.modifiers, varDecl.variableDeclarator.propertyName, TypeScript.ASTHelpers.getType(varDecl.variableDeclarator), varDecl.variableDeclarator.equalsValueClause, context); }; PullTypeResolver.prototype.resolvePropertySignature = function (varDecl, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.sentinelEmptyArray, varDecl.propertyName, TypeScript.getType(varDecl), null, context); + return this.resolveVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.sentinelEmptyArray, varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), null, context); }; PullTypeResolver.prototype.resolveVariableDeclarator = function (varDecl, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.getType(varDecl), varDecl.equalsValueClause, context); + return this.resolveVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), varDecl.equalsValueClause, context); }; PullTypeResolver.prototype.resolveParameterList = function (list, context) { @@ -40899,7 +41993,7 @@ var TypeScript; }; PullTypeResolver.prototype.resolveParameter = function (parameter, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.getType(parameter), parameter.equalsValueClause, context); + return this.resolveVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); }; PullTypeResolver.prototype.getEnumTypeSymbol = function (enumElement, context) { @@ -40932,7 +42026,7 @@ var TypeScript; var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - if (enclosingDecl && decl.kind == 2048 /* Parameter */) { + if (enclosingDecl && decl.kind === 2048 /* Parameter */) { enclosingDecl.ensureSymbolIsBound(); } @@ -40970,7 +42064,7 @@ var TypeScript; if (!(hasTypeExpr || init)) { var defaultType = this.semanticInfoChain.anyTypeSymbol; - if (declSymbol.isVarArg) { + if (declSymbol.isVarArg && this.cachedArrayInterfaceType()) { defaultType = this.createInstantiatedType(this.cachedArrayInterfaceType(), [defaultType]); } @@ -41012,7 +42106,7 @@ var TypeScript; } var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl ? wrapperDecl : enclosingDecl; + wrapperDecl = wrapperDecl || enclosingDecl; var typeExprSymbol = this.resolveTypeReference(typeExpr, context); @@ -41029,7 +42123,7 @@ var TypeScript; context.setTypeInContext(declParameterSymbol, typeExprSymbol); } } else { - if (typeExprSymbol == this.semanticInfoChain.anyTypeSymbol) { + if (typeExprSymbol === this.semanticInfoChain.anyTypeSymbol) { decl.setFlag(16777216 /* IsAnnotatedWithAny */); } @@ -41055,7 +42149,7 @@ var TypeScript; } } } - } else if (declSymbol.isVarArg && !(typeExprSymbol.isArrayNamedTypeReference() || typeExprSymbol == this.cachedArrayInterfaceType())) { + } else if (declSymbol.isVarArg && !(typeExprSymbol.isArrayNamedTypeReference() || typeExprSymbol === this.cachedArrayInterfaceType())) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); typeExprSymbol = this.getNewErrorTypeSymbol(); } @@ -41066,7 +42160,7 @@ var TypeScript; declParameterSymbol.type = typeExprSymbol; } - if (typeExprSymbol.kind == 16777216 /* FunctionType */ && !typeExprSymbol.getFunctionSymbol()) { + if (typeExprSymbol.kind === 16777216 /* FunctionType */ && !typeExprSymbol.getFunctionSymbol()) { typeExprSymbol.setFunctionSymbol(declSymbol); } } @@ -41081,7 +42175,7 @@ var TypeScript; var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; if (typeExprSymbol) { - context.pushContextualType(typeExprSymbol, context.inProvisionalResolution(), null); + context.pushNewContextualType(typeExprSymbol); } var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); @@ -41090,12 +42184,12 @@ var TypeScript; var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl ? wrapperDecl : enclosingDecl; + wrapperDecl = wrapperDecl || enclosingDecl; - var initExprSymbol = this.resolveAST(init, typeExprSymbol != null, context); + var initExprSymbol = this.resolveAST(init, typeExprSymbol !== null, context); if (typeExprSymbol) { - context.popContextualType(); + context.popAnyContextualType(); } if (!initExprSymbol) { @@ -41110,9 +42204,9 @@ var TypeScript; } } else { var initTypeSymbol = initExprSymbol.type; - var widenedInitTypeSymbol = this.widenType(initTypeSymbol, init.value, context); if (!hasTypeExpr) { + var widenedInitTypeSymbol = initTypeSymbol.widenedType(this, init.value, context); context.setTypeInContext(declSymbol, widenedInitTypeSymbol); if (declParameterSymbol) { @@ -41120,30 +42214,32 @@ var TypeScript; } if (this.compilationSettings.noImplicitAny()) { - if ((widenedInitTypeSymbol != initTypeSymbol) && (widenedInitTypeSymbol == this.semanticInfoChain.anyTypeSymbol)) { + if ((widenedInitTypeSymbol !== initTypeSymbol) && (widenedInitTypeSymbol === this.semanticInfoChain.anyTypeSymbol)) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); } } + + return widenedInitTypeSymbol; } } - return widenedInitTypeSymbol; + return initTypeSymbol; }; PullTypeResolver.prototype.typeCheckPropertySignature = function (varDecl, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.sentinelEmptyArray, varDecl.propertyName, TypeScript.getType(varDecl), null, context); + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.sentinelEmptyArray, varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), null, context); }; PullTypeResolver.prototype.typeCheckMemberVariableDeclaration = function (varDecl, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDecl, varDecl.modifiers, varDecl.variableDeclarator.propertyName, TypeScript.getType(varDecl), varDecl.variableDeclarator.equalsValueClause, context); + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDecl, varDecl.modifiers, varDecl.variableDeclarator.propertyName, TypeScript.ASTHelpers.getType(varDecl), varDecl.variableDeclarator.equalsValueClause, context); }; PullTypeResolver.prototype.typeCheckVariableDeclarator = function (varDecl, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.getType(varDecl), varDecl.equalsValueClause, context); + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), varDecl.equalsValueClause, context); }; PullTypeResolver.prototype.typeCheckParameter = function (parameter, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.getType(parameter), parameter.equalsValueClause, context); + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); }; PullTypeResolver.prototype.typeCheckVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { @@ -41199,7 +42295,7 @@ var TypeScript; } } else if (varDeclOrParameter.kind() !== 243 /* EnumElement */ && this.compilationSettings.noImplicitAny() && !this.isForInVariableDeclarator(varDeclOrParameter)) { var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl ? wrapperDecl : enclosingDecl; + wrapperDecl = wrapperDecl || enclosingDecl; if ((wrapperDecl.kind === 16384 /* Function */ || wrapperDecl.kind === 32768 /* ConstructorMethod */ || wrapperDecl.kind === 2097152 /* ConstructSignature */)) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [name.text(), enclosingDecl.name])); @@ -41211,7 +42307,7 @@ var TypeScript; } else if (TypeScript.hasFlag(parentDecl.flags, 8 /* Ambient */) && !TypeScript.hasFlag(wrapperDecl.flags, 2 /* Private */)) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [name.text(), enclosingDecl.name])); } - } else if (wrapperDecl.kind === 8388608 /* ObjectType */) { + } else if (decl.kind === 4096 /* Property */ && !declSymbol.getContainer().isNamedTypeSymbol()) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Member_0_of_object_type_implicitly_has_an_any_type, [name.text()])); } else if (wrapperDecl.kind !== 268435456 /* CatchBlock */) { if (!TypeScript.hasFlag(wrapperDecl.flags, 8 /* Ambient */)) { @@ -41225,16 +42321,16 @@ var TypeScript; if (init && varDeclOrParameter.kind() === 242 /* Parameter */) { var containerSignature = enclosingDecl.getSignatureSymbol(); if (containerSignature && !containerSignature.isDefinition()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Default_arguments_are_not_allowed_in_an_overload_parameter)); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Default_arguments_are_only_allowed_in_implementation)); } } - if (declSymbol.kind != 2048 /* Parameter */ && (declSymbol.kind != 4096 /* Property */ || declSymbol.getContainer().isNamedTypeSymbol())) { + if (declSymbol.kind !== 2048 /* Parameter */ && (declSymbol.kind !== 4096 /* Property */ || declSymbol.getContainer().isNamedTypeSymbol())) { this.checkSymbolPrivacy(declSymbol, declSymbol.type, function (symbol) { return _this.variablePrivacyErrorReporter(varDeclOrParameter, declSymbol, symbol, context); }); } - if ((declSymbol.kind != 4096 /* Property */ && declSymbol.kind != 67108864 /* EnumMember */) || declSymbol.anyDeclHasFlag(8388608 /* PropertyParameter */)) { + if ((declSymbol.kind !== 4096 /* Property */ && declSymbol.kind !== 67108864 /* EnumMember */) || declSymbol.anyDeclHasFlag(8388608 /* PropertyParameter */)) { this.checkNameForCompilerGeneratedDeclarationCollision(varDeclOrParameter, true, name, context); } }; @@ -41245,15 +42341,14 @@ var TypeScript; PullTypeResolver.prototype.checkSuperCaptureVariableCollides = function (superAST, isDeclaration, context) { var enclosingDecl = this.getEnclosingDeclForAST(superAST); - var declPath = enclosingDecl.getParentPath(); var classSymbol = this.getContextualClassSymbolForEnclosingDecl(superAST, enclosingDecl); if (classSymbol && !classSymbol.anyDeclHasFlag(8 /* Ambient */)) { - if (superAST.kind() == 242 /* Parameter */) { + if (superAST.kind() === 242 /* Parameter */) { var enclosingAST = this.getASTForDecl(enclosingDecl); if (enclosingAST.kind() !== 218 /* ParenthesizedArrowFunctionExpression */ && enclosingAST.kind() !== 219 /* SimpleArrowFunctionExpression */) { - var block = enclosingDecl.kind == 65536 /* Method */ ? enclosingAST.block : enclosingAST.block; + var block = enclosingDecl.kind === 65536 /* Method */ ? enclosingAST.block : enclosingAST.block; if (!block) { return; } @@ -41279,8 +42374,8 @@ var TypeScript; var enclosingDecl = this.getEnclosingDeclForAST(_thisAST); - var enclosingModule = TypeScript.getEnclosingModuleDeclaration(_thisAST); - if (TypeScript.isAnyNameOfModule(enclosingModule, _thisAST)) { + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(_thisAST); + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, _thisAST)) { enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); } @@ -41310,11 +42405,21 @@ var TypeScript; var typeParameterDecl = this.semanticInfoChain.getDeclForAST(typeParameterAST); var typeParameterSymbol = typeParameterDecl.getSymbol(); + this.resolveFirstTypeParameterDeclaration(typeParameterSymbol, context); + + if (typeParameterSymbol.isResolved && this.canTypeCheckAST(typeParameterAST, context)) { + this.typeCheckTypeParameterDeclaration(typeParameterAST, context); + } + + return typeParameterSymbol; + }; + + PullTypeResolver.prototype.resolveFirstTypeParameterDeclaration = function (typeParameterSymbol, context) { + var typeParameterDecl = typeParameterSymbol.getDeclarations()[0]; + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecl); + if (typeParameterSymbol.isResolved || typeParameterSymbol.inResolution) { - if (typeParameterSymbol.isResolved && this.canTypeCheckAST(typeParameterAST, context)) { - this.typeCheckTypeParameterDeclaration(typeParameterAST, context); - } - return typeParameterSymbol; + return; } typeParameterSymbol.startResolving(); @@ -41328,18 +42433,27 @@ var TypeScript; } typeParameterSymbol.setResolved(); - - if (this.canTypeCheckAST(typeParameterAST, context)) { - this.setTypeChecked(typeParameterAST, context); - } - - return typeParameterSymbol; }; PullTypeResolver.prototype.typeCheckTypeParameterDeclaration = function (typeParameterAST, context) { this.setTypeChecked(typeParameterAST, context); - this.resolveAST(typeParameterAST.constraint, false, context); + var constraint = this.resolveAST(typeParameterAST.constraint, false, context); + + if (constraint) { + var typeParametersAST = typeParameterAST.parent; + var typeParameters = []; + for (var i = 0; i < typeParametersAST.nonSeparatorCount(); i++) { + var currentTypeParameterAST = typeParametersAST.nonSeparatorAt(i); + var currentTypeParameterDecl = this.semanticInfoChain.getDeclForAST(currentTypeParameterAST); + var currentTypeParameter = this.semanticInfoChain.getSymbolForDecl(currentTypeParameterDecl); + typeParameters[currentTypeParameter.pullSymbolID] = currentTypeParameter; + } + + if (constraint.wrapsSomeTypeParameter(typeParameters)) { + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list); + } + } }; PullTypeResolver.prototype.resolveConstraint = function (constraint, context) { @@ -41364,6 +42478,7 @@ var TypeScript; case 219 /* SimpleArrowFunctionExpression */: case 218 /* ParenthesizedArrowFunctionExpression */: case 222 /* FunctionExpression */: + case 215 /* ObjectLiteralExpression */: go = false; break; @@ -41451,20 +42566,12 @@ var TypeScript; var returnType = bestCommonReturnType; var returnExpression = returnExpressions[returnExpressionSymbols.indexOf(returnType)]; - if (useContextualType && returnType == this.semanticInfoChain.anyTypeSymbol) { - var contextualType = context.getContextualType(); - - if (contextualType) { - returnType = contextualType; - } - } - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); var functionSymbol = functionDecl.getSymbol(); if (returnType) { var previousReturnType = returnType; - var newReturnType = this.widenType(returnType, returnExpression, context); + var newReturnType = returnType.widenedType(this, returnExpression, context); signature.returnType = newReturnType; if (!TypeScript.ArrayUtilities.contains(returnExpressionSymbols, bestCommonReturnType)) { @@ -41474,7 +42581,7 @@ var TypeScript; if (this.compilationSettings.noImplicitAny()) { if (previousReturnType !== newReturnType && newReturnType === this.semanticInfoChain.anyTypeSymbol) { var functionName = enclosingDecl.name; - if (functionName == "") { + if (functionName === "") { functionName = enclosingDecl.getFunctionExpressionName(); } @@ -41500,28 +42607,26 @@ var TypeScript; var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - if (funcDeclAST.parameterList) { - for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveAST(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), false, context); - } + for (var i = 0; i < funcDeclAST.callSignature.parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveAST(funcDeclAST.callSignature.parameterList.parameters.nonSeparatorAt(i), false, context); } this.resolveAST(funcDeclAST.block, false, context); if (funcDecl.getSignatureSymbol() && funcDecl.getSignatureSymbol().isDefinition() && this.enclosingClassIsDerived(funcDecl.getParentDecl())) { if (!this.constructorHasSuperCall(funcDeclAST)) { - context.postDiagnostic(new TypeScript.Diagnostic(funcDeclAST.fileName(), this.semanticInfoChain.lineMap(funcDeclAST.fileName()), funcDeclAST.start(), 11, TypeScript.DiagnosticCode.Constructors_for_derived_classes_must_contain_a_super_call)); + context.postDiagnostic(new TypeScript.Diagnostic(funcDeclAST.fileName(), this.semanticInfoChain.lineMap(funcDeclAST.fileName()), funcDeclAST.start(), "constructor".length, TypeScript.DiagnosticCode.Constructors_for_derived_classes_must_contain_a_super_call)); } else if (this.superCallMustBeFirstStatementInConstructor(funcDecl)) { var firstStatement = this.getFirstStatementOfBlockOrNull(funcDeclAST.block); if (!firstStatement || !this.isSuperInvocationExpressionStatement(firstStatement)) { - context.postDiagnostic(new TypeScript.Diagnostic(funcDeclAST.fileName(), this.semanticInfoChain.lineMap(funcDeclAST.fileName()), funcDeclAST.start(), 11, TypeScript.DiagnosticCode.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties)); + context.postDiagnostic(new TypeScript.Diagnostic(funcDeclAST.fileName(), this.semanticInfoChain.lineMap(funcDeclAST.fileName()), funcDeclAST.start(), "constructor".length, TypeScript.DiagnosticCode.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties)); } } } this.validateVariableDeclarationGroups(funcDecl, context); - this.checkFunctionTypePrivacy(funcDeclAST, false, null, TypeScript.Parameters.fromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); + this.checkFunctionTypePrivacy(funcDeclAST, false, null, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.callSignature.parameterList), null, funcDeclAST.block, context); this.typeCheckCallBacks.push(function (context) { _this.typeCheckFunctionOverloads(funcDeclAST, context); @@ -41533,9 +42638,18 @@ var TypeScript; if (constructorDecl.block) { var foundSuperCall = false; var pre = function (ast, walker) { - if (_this.isSuperInvocationExpression(ast)) { - foundSuperCall = true; - walker.options.stopWalking = true; + switch (ast.kind()) { + case 129 /* FunctionDeclaration */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + case 215 /* ObjectLiteralExpression */: + walker.options.goChildren = false; + default: + if (_this.isSuperInvocationExpression(ast)) { + foundSuperCall = true; + walker.options.stopWalking = true; + } } }; @@ -41546,19 +42660,31 @@ var TypeScript; return false; }; - PullTypeResolver.prototype.typeCheckFunctionExpression = function (funcDecl, context) { - this.typeCheckAnyFunctionExpression(funcDecl, funcDecl.callSignature.typeParameterList, TypeScript.getType(funcDecl), funcDecl.block, null, context); + PullTypeResolver.prototype.typeCheckFunctionExpression = function (funcDecl, isContextuallyTyped, context) { + this.typeCheckAnyFunctionExpression(funcDecl, funcDecl.callSignature.typeParameterList, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), funcDecl.callSignature.typeAnnotation, funcDecl.block, null, isContextuallyTyped, context); }; PullTypeResolver.prototype.typeCheckCallSignature = function (funcDecl, context) { - this.typeCheckFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.getType(funcDecl), null, context); + this.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); }; PullTypeResolver.prototype.typeCheckConstructSignature = function (funcDecl, context) { - this.typeCheckFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.getType(funcDecl), null, context); + this.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); }; - PullTypeResolver.prototype.typeCheckFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameters, returnTypeAnnotation, block, context) { + PullTypeResolver.prototype.typeCheckMethodSignature = function (funcDecl, context) { + this.typeCheckAnyFunctionDeclaration(funcDecl, false, funcDecl.propertyName, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); + }; + + PullTypeResolver.prototype.typeCheckMemberFunctionDeclaration = function (funcDecl, context) { + this.typeCheckAnyFunctionDeclaration(funcDecl, TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */), funcDecl.propertyName, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, context); + }; + + PullTypeResolver.prototype.containsSingleThrowStatement = function (block) { + return block !== null && block.statements.childCount() === 1 && block.statements.childAt(0).kind() === 157 /* ThrowStatement */; + }; + + PullTypeResolver.prototype.typeCheckAnyFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameters, returnTypeAnnotation, block, context) { var _this = this; this.setTypeChecked(funcDeclAST, context); @@ -41578,22 +42704,9 @@ var TypeScript; this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); this.validateVariableDeclarationGroups(funcDecl, context); - this.checkFunctionTypePrivacy(funcDeclAST, isStatic, typeParameters, TypeScript.Parameters.fromParameterList(parameters), returnTypeAnnotation, block, context); + this.checkFunctionTypePrivacy(funcDeclAST, isStatic, typeParameters, TypeScript.ASTHelpers.parametersFromParameterList(parameters), returnTypeAnnotation, block, context); - var signature = funcDecl.getSignatureSymbol(); - - var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; - - if (funcDeclAST.kind() !== 143 /* ConstructSignature */ && block && returnTypeAnnotation != null && !hasReturn) { - var isVoidOrAny = this.isAnyOrEquivalent(signature.returnType) || signature.returnType === this.semanticInfoChain.voidTypeSymbol; - - if (!isVoidOrAny && !(block.statements.childCount() > 0 && block.statements.childAt(0).kind() === 157 /* ThrowStatement */)) { - var funcName = funcDecl.getDisplayName(); - funcName = funcName ? funcName : "expression"; - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Function_0_declared_a_non_void_return_type_but_has_no_return_expression, [funcName])); - } - } + this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(funcDecl, returnTypeAnnotation, funcDecl.getSignatureSymbol().returnType, block, context); if (funcDecl.kind === 16384 /* Function */) { this.checkNameForCompilerGeneratedDeclarationCollision(funcDeclAST, true, name, context); @@ -41604,6 +42717,20 @@ var TypeScript; }); }; + PullTypeResolver.prototype.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement = function (functionDecl, returnTypeAnnotation, returnTypeSymbol, block, context) { + var hasReturn = TypeScript.hasFlag(functionDecl.flags, 4194304 /* HasReturnStatement */); + + if (block !== null && returnTypeAnnotation !== null && !hasReturn) { + var isVoidOrAny = this.isAnyOrEquivalent(returnTypeSymbol) || returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol; + + if (!isVoidOrAny && !this.containsSingleThrowStatement(block)) { + var funcName = functionDecl.getDisplayName() || TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Function_declared_a_non_void_return_type_but_has_no_return_expression)); + } + } + }; + PullTypeResolver.prototype.typeCheckIndexSignature = function (funcDeclAST, context) { var _this = this; this.setTypeChecked(funcDeclAST, context); @@ -41614,16 +42741,16 @@ var TypeScript; var enclosingDecl = this.getEnclosingDecl(funcDecl); - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.getType(funcDeclAST), context); + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); this.validateVariableDeclarationGroups(funcDecl, context); - this.checkFunctionTypePrivacy(funcDeclAST, false, null, TypeScript.Parameters.fromParameter(funcDeclAST.parameter), TypeScript.getType(funcDeclAST), null, context); + this.checkFunctionTypePrivacy(funcDeclAST, false, null, TypeScript.ASTHelpers.parametersFromParameter(funcDeclAST.parameter), TypeScript.ASTHelpers.getType(funcDeclAST), null, context); var signature = funcDecl.getSignatureSymbol(); this.typeCheckCallBacks.push(function (context) { var parentSymbol = funcDecl.getSignatureSymbol().getContainer(); - var allIndexSignatures = _this.getBothKindsOfIndexSignatures(parentSymbol, context); + var allIndexSignatures = _this.getBothKindsOfIndexSignaturesExcludingAugmentedType(parentSymbol, context); var stringIndexSignature = allIndexSignatures.stringSignature; var numberIndexSignature = allIndexSignatures.numericSignature; var isNumericIndexer = numberIndexSignature === signature; @@ -41631,12 +42758,12 @@ var TypeScript; if (numberIndexSignature && stringIndexSignature && (isNumericIndexer || stringIndexSignature.getDeclarations()[0].getParentDecl() !== numberIndexSignature.getDeclarations()[0].getParentDecl())) { var comparisonInfo = new TypeComparisonInfo(); - if (!_this.sourceIsSubtypeOfTarget(numberIndexSignature.returnType, stringIndexSignature.returnType, funcDeclAST, context, comparisonInfo)) { + if (!_this.sourceIsAssignableToTarget(numberIndexSignature.returnType, stringIndexSignature.returnType, funcDeclAST, context, comparisonInfo)) { var enclosingSymbol = _this.getEnclosingSymbolForAST(funcDeclAST); if (comparisonInfo.message) { - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Numeric_indexer_type_0_must_be_a_subtype_of_string_indexer_type_1_NL_2, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol), comparisonInfo.message])); + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Numeric_indexer_type_0_must_be_assignable_to_string_indexer_type_1_NL_2, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol), comparisonInfo.message])); } else { - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Numeric_indexer_type_0_must_be_a_subtype_of_string_indexer_type_1, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol)])); + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Numeric_indexer_type_0_must_be_assignable_to_string_indexer_type_1, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol)])); } } } @@ -41657,7 +42784,7 @@ var TypeScript; if (indexerKindMatchesMemberNameKind || onlyStringIndexerIsPresent) { var comparisonInfo = new TypeComparisonInfo(); - if (!_this.sourceIsSubtypeOfTarget(allMembers[i].type, signature.returnType, funcDeclAST, context, comparisonInfo, false)) { + if (!_this.sourceIsAssignableToTarget(allMembers[i].type, signature.returnType, funcDeclAST, context, comparisonInfo, false)) { _this.reportErrorThatMemberIsNotSubtypeOfIndexer(allMembers[i], signature, funcDeclAST, context, comparisonInfo); } } @@ -41693,35 +42820,35 @@ var TypeScript; }; PullTypeResolver.prototype.resolveMemberFunctionDeclaration = function (funcDecl, context) { - return this.resolveFunctionDeclaration(funcDecl, TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */), funcDecl.propertyName, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.getType(funcDecl), funcDecl.block, context); + return this.resolveFunctionDeclaration(funcDecl, TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */), funcDecl.propertyName, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, context); }; PullTypeResolver.prototype.resolveCallSignature = function (funcDecl, context) { - return this.resolveFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.getType(funcDecl), null, context); + return this.resolveFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); }; PullTypeResolver.prototype.resolveConstructSignature = function (funcDecl, context) { - return this.resolveFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.getType(funcDecl), null, context); + return this.resolveFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); }; PullTypeResolver.prototype.resolveMethodSignature = function (funcDecl, context) { - return this.resolveFunctionDeclaration(funcDecl, false, funcDecl.propertyName, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.getType(funcDecl), null, context); + return this.resolveFunctionDeclaration(funcDecl, false, funcDecl.propertyName, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); }; PullTypeResolver.prototype.resolveAnyFunctionDeclaration = function (funcDecl, context) { - return this.resolveFunctionDeclaration(funcDecl, TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */), funcDecl.identifier, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.getType(funcDecl), funcDecl.block, context); + return this.resolveFunctionDeclaration(funcDecl, TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */), funcDecl.identifier, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, context); }; PullTypeResolver.prototype.resolveFunctionExpression = function (funcDecl, isContextuallyTyped, context) { - return this.resolveAnyFunctionExpression(funcDecl, funcDecl.callSignature.typeParameterList, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList), TypeScript.getType(funcDecl), funcDecl.block, null, isContextuallyTyped, context); + return this.resolveAnyFunctionExpression(funcDecl, funcDecl.callSignature.typeParameterList, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, null, isContextuallyTyped, context); }; PullTypeResolver.prototype.resolveSimpleArrowFunctionExpression = function (funcDecl, isContextuallyTyped, context) { - return this.resolveAnyFunctionExpression(funcDecl, null, TypeScript.Parameters.fromIdentifier(funcDecl.identifier), null, funcDecl.block, funcDecl.expression, isContextuallyTyped, context); + return this.resolveAnyFunctionExpression(funcDecl, null, TypeScript.ASTHelpers.parametersFromIdentifier(funcDecl.identifier), null, funcDecl.block, funcDecl.expression, isContextuallyTyped, context); }; PullTypeResolver.prototype.resolveParenthesizedArrowFunctionExpression = function (funcDecl, isContextuallyTyped, context) { - return this.resolveAnyFunctionExpression(funcDecl, funcDecl.callSignature.typeParameterList, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList), TypeScript.getType(funcDecl), funcDecl.block, funcDecl.expression, isContextuallyTyped, context); + return this.resolveAnyFunctionExpression(funcDecl, funcDecl.callSignature.typeParameterList, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, funcDecl.expression, isContextuallyTyped, context); }; PullTypeResolver.prototype.getEnclosingClassDeclaration = function (ast) { @@ -41786,18 +42913,16 @@ var TypeScript; } signature.startResolving(); - if (funcDeclAST.parameterList) { - var prevInTypeCheck = context.inTypeCheck; + var prevInTypeCheck = context.inTypeCheck; - context.inTypeCheck = false; + context.inTypeCheck = false; - for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), context); - } - - context.inTypeCheck = prevInTypeCheck; + for (var i = 0; i < funcDeclAST.callSignature.parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(funcDeclAST.callSignature.parameterList.parameters.nonSeparatorAt(i), context); } + context.inTypeCheck = prevInTypeCheck; + if (signature.isGeneric()) { if (funcSymbol) { funcSymbol.type.setHasGenericSignature(); @@ -41855,9 +42980,9 @@ var TypeScript; if (signature.inResolution) { if (funcDeclAST.typeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(TypeScript.getType(funcDeclAST), context); + var returnTypeSymbol = this.resolveTypeReference(TypeScript.ASTHelpers.getType(funcDeclAST), context); if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(TypeScript.getType(funcDeclAST), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(TypeScript.ASTHelpers.getType(funcDeclAST), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); signature.returnType = this.getNewErrorTypeSymbol(); hadError = true; } else { @@ -41891,7 +43016,7 @@ var TypeScript; } if (funcDeclAST.typeAnnotation) { - returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.getType(funcDeclAST), context); + returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); if (!returnTypeSymbol) { signature.returnType = this.getNewErrorTypeSymbol(); @@ -41901,16 +43026,6 @@ var TypeScript; } } else { signature.returnType = this.semanticInfoChain.anyTypeSymbol; - var parentDeclFlags = 0 /* None */; - if (TypeScript.hasFlag(funcDecl.kind, 65536 /* Method */) || TypeScript.hasFlag(funcDecl.kind, 32768 /* ConstructorMethod */)) { - var parentDecl = funcDecl.getParentDecl(); - parentDeclFlags = parentDecl.flags; - } - - if (this.compilationSettings.noImplicitAny() && (!TypeScript.hasFlag(parentDeclFlags, 8 /* Ambient */) || (TypeScript.hasFlag(parentDeclFlags, 8 /* Ambient */) && !TypeScript.hasFlag(funcDecl.flags, 2 /* Private */)))) { - var funcDeclASTName = name; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, ["Indexer"])); - } } if (!hadError) { @@ -41949,7 +43064,7 @@ var TypeScript; if (signature) { if (signature.isResolved) { if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); + this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); } return funcSymbol; } @@ -42073,7 +43188,7 @@ var TypeScript; } if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); + this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); } return funcSymbol; @@ -42081,7 +43196,7 @@ var TypeScript; PullTypeResolver.prototype.resolveGetterReturnTypeAnnotation = function (getterFunctionDeclarationAst, enclosingDecl, context) { if (getterFunctionDeclarationAst && getterFunctionDeclarationAst.typeAnnotation) { - return this.resolveTypeReference(TypeScript.getType(getterFunctionDeclarationAst), context); + return this.resolveTypeReference(TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), context); } return null; @@ -42090,7 +43205,7 @@ var TypeScript; PullTypeResolver.prototype.resolveSetterArgumentTypeAnnotation = function (setterFunctionDeclarationAst, enclosingDecl, context) { if (setterFunctionDeclarationAst && setterFunctionDeclarationAst.parameterList && setterFunctionDeclarationAst.parameterList.parameters.nonSeparatorCount() > 0) { var parameter = setterFunctionDeclarationAst.parameterList.parameters.nonSeparatorAt(0); - return this.resolveTypeReference(TypeScript.getType(parameter), context); + return this.resolveTypeReference(TypeScript.ASTHelpers.getType(parameter), context); } return null; @@ -42129,7 +43244,7 @@ var TypeScript; accessorSymbol.startResolving(); if (hasGetter) { - getterSymbol = this.resolveGetAccessorDeclaration(getterFunctionDeclarationAst, getterFunctionDeclarationAst.parameterList, TypeScript.getType(getterFunctionDeclarationAst), getterFunctionDeclarationAst.block, setterAnnotatedType, context); + getterSymbol = this.resolveGetAccessorDeclaration(getterFunctionDeclarationAst, getterFunctionDeclarationAst.parameterList, TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), getterFunctionDeclarationAst.block, setterAnnotatedType, context); } if (hasSetter) { @@ -42156,7 +43271,7 @@ var TypeScript; } } - if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol)) { + if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { accessorSymbol.type = this.getNewErrorTypeSymbol(); } else { accessorSymbol.type = getterSuppliedTypeSymbol; @@ -42189,12 +43304,12 @@ var TypeScript; var getterSymbol = accessorSymbol.getGetter(); var setterSymbol = accessorSymbol.getSetter(); - var isGetter = funcDeclAst.kind() == 139 /* GetAccessor */; + var isGetter = funcDeclAst.kind() === 139 /* GetAccessor */; if (isGetter) { var getterFunctionDeclarationAst = funcDeclAst; - context.pushContextualType(getterSymbol.type, context.inProvisionalResolution(), null); + context.pushNewContextualType(getterSymbol.type); this.typeCheckGetAccessorDeclaration(getterFunctionDeclarationAst, context); - context.popContextualType(); + context.popAnyContextualType(); } else { var setterFunctionDeclarationAst = funcDeclAst; this.typeCheckSetAccessorDeclaration(setterFunctionDeclarationAst, context); @@ -42272,7 +43387,7 @@ var TypeScript; var setterSuppliedTypeSymbol = setterParameters[0].type; var getterSuppliedTypeSymbol = getterSig.returnType; - if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol)) { + if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type)); } } @@ -42283,7 +43398,7 @@ var TypeScript; var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); var accessorSymbol = funcDecl.getSymbol(); - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.getType(funcDeclAST), context); + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); this.resolveAST(funcDeclAST.block, false, context); @@ -42291,10 +43406,10 @@ var TypeScript; var enclosingDecl = this.getEnclosingDecl(funcDecl); - var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; var funcNameAST = funcDeclAST.propertyName; - if (!hasReturn && !(funcDeclAST.block.statements.childCount() > 0 && funcDeclAST.block.statements.childAt(0).kind() === 157 /* ThrowStatement */)) { + if (!hasReturn && !this.containsSingleThrowStatement(funcDeclAST.block)) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getters_must_return_a_value)); } @@ -42304,18 +43419,18 @@ var TypeScript; var setterIsPrivate = TypeScript.hasFlag(setterDecl.flags, 2 /* Private */); var getterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); - if (getterIsPrivate != setterIsPrivate) { + if (getterIsPrivate !== setterIsPrivate) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility)); } this.checkIfGetterAndSetterTypeMatch(funcDeclAST, context); } - this.checkFunctionTypePrivacy(funcDeclAST, TypeScript.hasModifier(funcDeclAST.modifiers, 16 /* Static */), null, TypeScript.Parameters.fromParameterList(funcDeclAST.parameterList), TypeScript.getType(funcDeclAST), funcDeclAST.block, context); + this.checkFunctionTypePrivacy(funcDeclAST, TypeScript.hasModifier(funcDeclAST.modifiers, 16 /* Static */), null, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), TypeScript.ASTHelpers.getType(funcDeclAST), funcDeclAST.block, context); }; PullTypeResolver.hasSetAccessorParameterTypeAnnotation = function (setAccessor) { - return setAccessor.parameterList && setAccessor.parameterList.parameters.nonSeparatorCount() > 0 && setAccessor.parameterList.parameters.nonSeparatorAt(0).typeAnnotation != null; + return setAccessor.parameterList && setAccessor.parameterList.parameters.nonSeparatorCount() > 0 && setAccessor.parameterList.parameters.nonSeparatorAt(0).typeAnnotation !== null; }; PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, parameterList, context) { @@ -42350,10 +43465,6 @@ var TypeScript; signature.returnType = this.semanticInfoChain.voidTypeSymbol; - if (signature.hasAGenericParameter) { - setterTypeSymbol.setHasGenericSignature(); - } - if (!hadError) { signature.setResolved(); } @@ -42376,7 +43487,7 @@ var TypeScript; this.validateVariableDeclarationGroups(funcDecl, context); - var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; var getter = accessorSymbol.getGetter(); @@ -42387,7 +43498,7 @@ var TypeScript; var getterIsPrivate = TypeScript.hasFlag(getterDecl.flags, 2 /* Private */); var setterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); - if (getterIsPrivate != setterIsPrivate) { + if (getterIsPrivate !== setterIsPrivate) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility)); } @@ -42395,13 +43506,13 @@ var TypeScript; } else { if (this.compilationSettings.noImplicitAny()) { var setterFunctionDeclarationAst = funcDeclAST; - if (!PullTypeResolver.hasSetAccessorParameterTypeAnnotation(setterFunctionDeclarationAst) && accessorSymbol.type == this.semanticInfoChain.anyTypeSymbol) { + if (!PullTypeResolver.hasSetAccessorParameterTypeAnnotation(setterFunctionDeclarationAst) && accessorSymbol.type === this.semanticInfoChain.anyTypeSymbol) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_get_accessor_and_parameter_type_annotation_on_set_accessor_implicitly_has_an_any_type, [setterFunctionDeclarationAst.propertyName.text()])); } } } - this.checkFunctionTypePrivacy(funcDeclAST, TypeScript.hasModifier(funcDeclAST.modifiers, 16 /* Static */), null, TypeScript.Parameters.fromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); + this.checkFunctionTypePrivacy(funcDeclAST, TypeScript.hasModifier(funcDeclAST.modifiers, 16 /* Static */), null, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); }; PullTypeResolver.prototype.resolveList = function (list, context) { @@ -42497,7 +43608,7 @@ var TypeScript; var nodeType = unaryExpression.kind(); var expression = this.resolveAST(unaryExpression.operand, false, context); - if (nodeType == 164 /* PlusExpression */ || nodeType == 165 /* NegateExpression */ || nodeType == 166 /* BitwiseNotExpression */) { + if (nodeType === 164 /* PlusExpression */ || nodeType == 165 /* NegateExpression */ || nodeType == 166 /* BitwiseNotExpression */) { return; } @@ -42632,14 +43743,14 @@ var TypeScript; var enclosingSymbol = this.getEnclosingSymbolForAST(binaryExpression); var isValidLHS = this.isAnyOrEquivalent(lhsType) || lhsType.isObject() || lhsType.isTypeParameter(); - var isValidRHS = this.isAnyOrEquivalent(rhsType) || this.typeIsSubtypeOfFunction(rhsType, binaryExpression, context); + var isValidRHS = this.isAnyOrEquivalent(rhsType) || this.typeIsAssignableToFunction(rhsType, binaryExpression, context); if (!isValidLHS) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter)); } if (!isValidRHS) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_a_subtype_of_the_Function_interface_type)); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type)); } }; @@ -42650,8 +43761,6 @@ var TypeScript; this.resolveAST(commaExpression.left, false, context); } - var rhsType = this.resolveAST(commaExpression.right, false, context).type; - return this.resolveAST(commaExpression.right, false, context).type; }; @@ -42678,7 +43787,7 @@ var TypeScript; } if (!isValidRHS) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter)); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter)); } }; @@ -42707,29 +43816,27 @@ var TypeScript; PullTypeResolver.prototype.typeCheckForInStatement = function (forInStatement, context) { this.setTypeChecked(forInStatement, context); - var rhsType = this.resolveAST(forInStatement.expression, false, context).type; - var lval = forInStatement.variableDeclaration || forInStatement.left; - - var varSym = this.resolveAST(lval, false, context); - if (forInStatement.variableDeclaration) { var declaration = forInStatement.variableDeclaration; - var varDecl = declaration.declarators.nonSeparatorAt(0); - if (varDecl.typeAnnotation) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(lval, TypeScript.DiagnosticCode.Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation)); + if (declaration.declarators.nonSeparatorCount() === 1) { + var varDecl = declaration.declarators.nonSeparatorAt(0); + + if (varDecl.typeAnnotation) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declaration, TypeScript.DiagnosticCode.Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation)); + } } + } else { + var varSym = this.resolveAST(forInStatement.left, false, context); + var isStringOrNumber = varSym.type === this.semanticInfoChain.stringTypeSymbol || this.isAnyOrEquivalent(varSym.type); - var varSym = this.getSymbolForAST(varDecl, context); + if (!isStringOrNumber) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(forInStatement.left, TypeScript.DiagnosticCode.Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any)); + } } - var isStringOrNumber = varSym.type === this.semanticInfoChain.stringTypeSymbol || this.isAnyOrEquivalent(varSym.type); - - var isValidRHS = rhsType && (this.isAnyOrEquivalent(rhsType) || !rhsType.isPrimitive()); - - if (!isStringOrNumber) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(lval, TypeScript.DiagnosticCode.Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any)); - } + var rhsType = this.resolveAST(forInStatement.expression, false, context).type; + var isValidRHS = rhsType && (this.isAnyOrEquivalent(rhsType) || rhsType.isObject() || rhsType.isTypeParameter()); if (!isValidRHS) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(forInStatement.expression, TypeScript.DiagnosticCode.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter)); @@ -42908,23 +44015,23 @@ var TypeScript; if (enclosingFunction) { var enclosingDeclAST = this.getASTForDecl(enclosingFunction); - var typeAnnotation = TypeScript.getType(enclosingDeclAST); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); if (typeAnnotation) { var returnTypeAnnotationSymbol = this.resolveTypeReference(typeAnnotation, context); if (returnTypeAnnotationSymbol) { isContextuallyTyped = true; - context.pushContextualType(returnTypeAnnotationSymbol, context.inProvisionalResolution(), null); + context.pushNewContextualType(returnTypeAnnotationSymbol); } } else { var currentContextualType = context.getContextualType(); if (currentContextualType && currentContextualType.isFunction()) { - var currentContextTypeDecls = currentContextualType.getDeclarations(); - var currentContextualTypeSignatureSymbol = currentContextTypeDecls && currentContextTypeDecls.length > 0 ? currentContextTypeDecls[0].getSignatureSymbol() : currentContextualType.getCallSignatures()[0]; + var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); + var currentContextualTypeSignatureSymbol = contextualSignatures[0]; var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; if (currentContextualTypeReturnTypeSymbol) { isContextuallyTyped = true; - context.pushContextualType(currentContextualTypeReturnTypeSymbol, context.inProvisionalResolution(), null); + context.propagateContextualType(currentContextualTypeReturnTypeSymbol); } } } @@ -42932,7 +44039,7 @@ var TypeScript; var result = this.resolveAST(expression, isContextuallyTyped, context).type; if (isContextuallyTyped) { - context.popContextualType(); + context.popAnyContextualType(); } return result; @@ -42959,7 +44066,7 @@ var TypeScript; if (enclosingFunction) { var enclosingDeclAST = this.getASTForDecl(enclosingFunction); - var typeAnnotation = TypeScript.getType(enclosingDeclAST); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); if (typeAnnotation || enclosingFunction.kind === 262144 /* GetAccessor */) { var signatureSymbol = enclosingFunction.getSignatureSymbol(); var sigReturnType = signatureSymbol.returnType; @@ -42968,22 +44075,6 @@ var TypeScript; var comparisonInfo = new TypeComparisonInfo(); var upperBound = null; - if (expressionType.isTypeParameter()) { - upperBound = expressionType.getConstraint(); - - if (upperBound) { - expressionType = upperBound; - } - } - - if (sigReturnType.isTypeParameter()) { - upperBound = sigReturnType.getConstraint(); - - if (upperBound) { - sigReturnType = upperBound; - } - } - this.resolveDeclaredSymbol(expressionType, context); this.resolveDeclaredSymbol(sigReturnType, context); @@ -43081,8 +44172,11 @@ var TypeScript; var breakableLabels = this.getEnclosingLabels(ast, true, false); - if (TypeScript.ArrayUtilities.contains(breakableLabels, labelIdentifier)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast.identifier, TypeScript.DiagnosticCode.Duplicate_identifier_0, [labelIdentifier])); + var matchingLabel = TypeScript.ArrayUtilities.firstOrDefault(breakableLabels, function (s) { + return s.identifier.valueText() === labelIdentifier; + }); + if (matchingLabel) { + context.postDiagnostic(this.semanticInfoChain.duplicateIdentifierDiagnosticFromAST(ast.identifier, labelIdentifier, matchingLabel)); } this.resolveAST(ast.statement, false, context); @@ -43157,13 +44251,13 @@ var TypeScript; return false; }; - PullTypeResolver.prototype.inIterationStatement = function (ast) { + PullTypeResolver.prototype.inIterationStatement = function (ast, crossFunctions) { while (ast) { if (this.isIterationStatement(ast)) { return true; } - if (this.isAnyFunctionExpressionOrDeclaration(ast)) { + if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { return false; } @@ -43181,10 +44275,10 @@ var TypeScript; if (ast.kind() === 160 /* LabeledStatement */) { var labeledStatement = ast; if (breakable) { - result.push(labeledStatement.identifier.valueText()); + result.push(labeledStatement); } else { if (this.labelIsOnContinuableConstruct(labeledStatement.statement)) { - result.push(labeledStatement.identifier.valueText()); + result.push(labeledStatement); } } } @@ -43202,15 +44296,23 @@ var TypeScript; PullTypeResolver.prototype.typeCheckContinueStatement = function (ast, context) { this.setTypeChecked(ast, context); - if (!this.inIterationStatement(ast)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.continue_statement_can_only_be_used_within_an_enclosing_iteration_statement)); + if (!this.inIterationStatement(ast, false)) { + if (this.inIterationStatement(ast, true)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Jump_target_cannot_cross_function_boundary)); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.continue_statement_can_only_be_used_within_an_enclosing_iteration_statement)); + } } else if (ast.identifier) { var continuableLabels = this.getEnclosingLabels(ast, false, false); - if (!TypeScript.ArrayUtilities.contains(continuableLabels, ast.identifier.valueText())) { + if (!TypeScript.ArrayUtilities.any(continuableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { var continuableLabels = this.getEnclosingLabels(ast, false, true); - if (TypeScript.ArrayUtilities.contains(continuableLabels, ast.identifier.valueText())) { + if (TypeScript.ArrayUtilities.any(continuableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Jump_target_cannot_cross_function_boundary)); } else { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Jump_target_not_found)); @@ -43233,16 +44335,24 @@ var TypeScript; if (ast.identifier) { var breakableLabels = this.getEnclosingLabels(ast, true, false); - if (!TypeScript.ArrayUtilities.contains(breakableLabels, ast.identifier.valueText())) { + if (!TypeScript.ArrayUtilities.any(breakableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { var breakableLabels = this.getEnclosingLabels(ast, true, true); - if (TypeScript.ArrayUtilities.contains(breakableLabels, ast.identifier.valueText())) { + if (TypeScript.ArrayUtilities.any(breakableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Jump_target_cannot_cross_function_boundary)); } else { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Jump_target_not_found)); } } - } else if (!this.inIterationStatement(ast) && !this.inSwitchStatement(ast)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement)); + } else if (!this.inIterationStatement(ast, false) && !this.inSwitchStatement(ast)) { + if (this.inIterationStatement(ast, true)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Jump_target_cannot_cross_function_boundary)); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement)); + } } }; @@ -43257,6 +44367,10 @@ var TypeScript; return symbol; } + if (ast.isExpression() && !isTypesOnlyLocation(ast)) { + return this.resolveExpressionAST(ast, isContextuallyTyped, context); + } + var nodeType = ast.kind(); switch (nodeType) { @@ -43322,9 +44436,6 @@ var TypeScript; case 133 /* ImportDeclaration */: return this.resolveImportDeclaration(ast, context); - case 215 /* ObjectLiteralExpression */: - return this.resolveObjectLiteralExpression(ast, isContextuallyTyped, context); - case 240 /* SimplePropertyAssignment */: return this.resolveSimplePropertyAssignment(ast, isContextuallyTyped, context); @@ -43332,14 +44443,8 @@ var TypeScript; return this.resolveFunctionPropertyAssignment(ast, isContextuallyTyped, context); case 11 /* IdentifierName */: - if (isTypesOnlyLocation(ast)) { - return this.resolveTypeNameExpression(ast, context); - } else { - return this.resolveNameExpression(ast, context); - } - - case 212 /* MemberAccessExpression */: - return this.resolveMemberAccessExpression(ast, context); + TypeScript.Debug.assert(isTypesOnlyLocation(ast)); + return this.resolveTypeNameExpression(ast, context); case 121 /* QualifiedName */: return this.resolveQualifiedName(ast, context); @@ -43372,6 +44477,94 @@ var TypeScript; case 129 /* FunctionDeclaration */: return this.resolveAnyFunctionDeclaration(ast, context); + case 244 /* TypeAnnotation */: + return this.resolveTypeAnnotation(ast, context); + + case 134 /* ExportAssignment */: + return this.resolveExportAssignmentStatement(ast, context); + + case 157 /* ThrowStatement */: + return this.resolveThrowStatement(ast, context); + + case 149 /* ExpressionStatement */: + return this.resolveExpressionStatement(ast, context); + + case 154 /* ForStatement */: + return this.resolveForStatement(ast, context); + + case 155 /* ForInStatement */: + return this.resolveForInStatement(ast, context); + + case 158 /* WhileStatement */: + return this.resolveWhileStatement(ast, context); + + case 161 /* DoStatement */: + return this.resolveDoStatement(ast, context); + + case 147 /* IfStatement */: + return this.resolveIfStatement(ast, context); + + case 235 /* ElseClause */: + return this.resolveElseClause(ast, context); + + case 146 /* Block */: + return this.resolveBlock(ast, context); + + case 148 /* VariableStatement */: + return this.resolveVariableStatement(ast, context); + + case 163 /* WithStatement */: + return this.resolveWithStatement(ast, context); + + case 159 /* TryStatement */: + return this.resolveTryStatement(ast, context); + + case 236 /* CatchClause */: + return this.resolveCatchClause(ast, context); + + case 237 /* FinallyClause */: + return this.resolveFinallyClause(ast, context); + + case 150 /* ReturnStatement */: + return this.resolveReturnStatement(ast, context); + + case 151 /* SwitchStatement */: + return this.resolveSwitchStatement(ast, context); + + case 153 /* ContinueStatement */: + return this.resolveContinueStatement(ast, context); + + case 152 /* BreakStatement */: + return this.resolveBreakStatement(ast, context); + + case 160 /* LabeledStatement */: + return this.resolveLabeledStatement(ast, context); + } + + return this.semanticInfoChain.anyTypeSymbol; + }; + + PullTypeResolver.prototype.resolveExpressionAST = function (ast, isContextuallyOrInferentiallyTyped, context) { + var expressionSymbol = this.resolveExpressionWorker(ast, isContextuallyOrInferentiallyTyped, context); + + if (isContextuallyOrInferentiallyTyped && context.isInferentiallyTyping()) { + return this.alterPotentialGenericFunctionTypeToInstantiatedFunctionTypeForTypeArgumentInference(expressionSymbol, context); + } else { + return expressionSymbol; + } + }; + + PullTypeResolver.prototype.resolveExpressionWorker = function (ast, isContextuallyTyped, context) { + switch (ast.kind()) { + case 215 /* ObjectLiteralExpression */: + return this.resolveObjectLiteralExpression(ast, isContextuallyTyped, context); + + case 11 /* IdentifierName */: + return this.resolveNameExpression(ast, context); + + case 212 /* MemberAccessExpression */: + return this.resolveMemberAccessExpression(ast, context); + case 222 /* FunctionExpression */: return this.resolveFunctionExpression(ast, isContextuallyTyped, context); @@ -43399,12 +44592,6 @@ var TypeScript; case 220 /* CastExpression */: return this.resolveCastExpression(ast, context); - case 244 /* TypeAnnotation */: - return this.resolveTypeAnnotation(ast, context); - - case 134 /* ExportAssignment */: - return this.resolveExportAssignmentStatement(ast, context); - case 13 /* NumericLiteral */: return this.semanticInfoChain.numberTypeSymbol; @@ -43486,9 +44673,6 @@ var TypeScript; case 171 /* TypeOfExpression */: return this.resolveTypeOfExpression(ast, context); - case 157 /* ThrowStatement */: - return this.resolveThrowStatement(ast, context); - case 170 /* DeleteExpression */: return this.resolveDeleteExpression(ast, context); @@ -43501,9 +44685,6 @@ var TypeScript; case 217 /* ParenthesizedExpression */: return this.resolveParenthesizedExpression(ast, context); - case 149 /* ExpressionStatement */: - return this.resolveExpressionStatement(ast, context); - case 200 /* InstanceOfExpression */: return this.resolveInstanceOfExpression(ast, context); @@ -43513,59 +44694,11 @@ var TypeScript; case 201 /* InExpression */: return this.resolveInExpression(ast, context); - case 154 /* ForStatement */: - return this.resolveForStatement(ast, context); - - case 155 /* ForInStatement */: - return this.resolveForInStatement(ast, context); - - case 158 /* WhileStatement */: - return this.resolveWhileStatement(ast, context); - - case 161 /* DoStatement */: - return this.resolveDoStatement(ast, context); - - case 147 /* IfStatement */: - return this.resolveIfStatement(ast, context); - - case 235 /* ElseClause */: - return this.resolveElseClause(ast, context); - - case 146 /* Block */: - return this.resolveBlock(ast, context); - - case 148 /* VariableStatement */: - return this.resolveVariableStatement(ast, context); - - case 163 /* WithStatement */: - return this.resolveWithStatement(ast, context); - - case 159 /* TryStatement */: - return this.resolveTryStatement(ast, context); - - case 236 /* CatchClause */: - return this.resolveCatchClause(ast, context); - - case 237 /* FinallyClause */: - return this.resolveFinallyClause(ast, context); - - case 150 /* ReturnStatement */: - return this.resolveReturnStatement(ast, context); - - case 151 /* SwitchStatement */: - return this.resolveSwitchStatement(ast, context); - - case 153 /* ContinueStatement */: - return this.resolveContinueStatement(ast, context); - - case 152 /* BreakStatement */: - return this.resolveBreakStatement(ast, context); - - case 160 /* LabeledStatement */: - return this.resolveLabeledStatement(ast, context); + case 223 /* OmittedExpression */: + return this.semanticInfoChain.undefinedTypeSymbol; } - return this.semanticInfoChain.anyTypeSymbol; + TypeScript.Debug.fail("resolveExpressionASTWorker: Missing expression kind: " + TypeScript.SyntaxKind[ast.kind()]); }; PullTypeResolver.prototype.typeCheckAST = function (ast, isContextuallyTyped, context) { @@ -43644,8 +44777,25 @@ var TypeScript; return; case 222 /* FunctionExpression */: - this.typeCheckFunctionExpression(ast, context); - break; + this.typeCheckFunctionExpression(ast, isContextuallyTyped, context); + return; + + case 137 /* ConstructorDeclaration */: + this.typeCheckConstructorDeclaration(ast, context); + return; + + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + this.typeCheckAccessorDeclaration(ast, context); + return; + + case 135 /* MemberFunctionDeclaration */: + this.typeCheckMemberFunctionDeclaration(ast, context); + return; + + case 145 /* MethodSignature */: + this.typeCheckMethodSignature(ast, context); + return; case 144 /* IndexSignature */: this.typeCheckIndexSignature(ast, context); @@ -43653,24 +44803,24 @@ var TypeScript; case 142 /* CallSignature */: this.typeCheckCallSignature(ast, context); - break; + return; case 143 /* ConstructSignature */: this.typeCheckConstructSignature(ast, context); - break; + return; case 129 /* FunctionDeclaration */: { var funcDecl = ast; - this.typeCheckFunctionDeclaration(funcDecl, TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */), funcDecl.identifier, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.getType(funcDecl), funcDecl.block, context); + this.typeCheckAnyFunctionDeclaration(funcDecl, TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */), funcDecl.identifier, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, context); return; } case 219 /* SimpleArrowFunctionExpression */: - this.typeCheckSimpleArrowFunctionExpression(ast, context); + this.typeCheckSimpleArrowFunctionExpression(ast, isContextuallyTyped, context); return; case 218 /* ParenthesizedArrowFunctionExpression */: - this.typeCheckParenthesizedArrowFunctionExpression(ast, context); + this.typeCheckParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); return; case 214 /* ArrayLiteralExpression */: @@ -43758,36 +44908,112 @@ var TypeScript; PullTypeResolver.prototype.resolveNameExpression = function (nameAST, context) { var nameSymbol = this.getSymbolForAST(nameAST, context); - var foundCached = nameSymbol != null; + var foundCached = nameSymbol !== null; if (!foundCached || this.canTypeCheckAST(nameAST, context)) { if (this.canTypeCheckAST(nameAST, context)) { this.typeCheckNameExpression(nameAST, context); } - nameSymbol = this.computeNameExpression(nameAST, context, true); + nameSymbol = this.computeNameExpression(nameAST, context); } this.resolveDeclaredSymbol(nameSymbol, context); - if (nameSymbol && (nameSymbol.type != this.semanticInfoChain.anyTypeSymbol || nameSymbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { + if (nameSymbol && (nameSymbol.type !== this.semanticInfoChain.anyTypeSymbol || nameSymbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { this.setSymbolForAST(nameAST, nameSymbol, context); } return nameSymbol; }; - PullTypeResolver.prototype.isSomeFunctionScope = function (declPath) { - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - if (decl.kind & 1032192 /* SomeFunction */) { - return true; - } + PullTypeResolver.prototype.isInEnumDecl = function (decl) { + if (decl.kind & 64 /* Enum */) { + return true; } + var declPath = decl.getParentPath(); + + var disallowedKinds = 164 /* SomeContainer */ | 58728795 /* SomeType */; + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + + if (decl.kind & 64 /* Enum */) { + return true; + } + + if (decl.kind & disallowedKinds) { + return false; + } + } return false; }; - PullTypeResolver.prototype.computeNameExpression = function (nameAST, context, reportDiagnostics) { + PullTypeResolver.prototype.getSomeInnermostFunctionScopeDecl = function (declPath) { + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + if (decl.kind & 1032192 /* SomeFunction */) { + return decl; + } + } + + return null; + }; + + PullTypeResolver.prototype.isFromFunctionScope = function (nameSymbol, functionScopeDecl) { + var _this = this; + return TypeScript.ArrayUtilities.any(nameSymbol.getDeclarations(), function (nameSymbolDecl) { + return _this.getSomeInnermostFunctionScopeDecl(nameSymbolDecl.getParentPath()) === functionScopeDecl; + }); + }; + + PullTypeResolver.prototype.findConstructorDeclOfEnclosingType = function (decl) { + var current = decl; + while (current) { + if (TypeScript.hasFlag(current.kind, 4096 /* Property */)) { + var parentDecl = current.getParentDecl(); + if (TypeScript.hasFlag(parentDecl.kind, 8 /* Class */)) { + return TypeScript.ArrayUtilities.lastOrDefault(parentDecl.getChildDecls(), function (decl) { + return TypeScript.hasFlag(decl.kind, 32768 /* ConstructorMethod */); + }); + } + } + + if (TypeScript.hasFlag(current.kind, 164 /* SomeContainer */)) { + return null; + } + + current = current.getParentDecl(); + } + return null; + }; + + PullTypeResolver.prototype.checkNameAsPartOfInitializerExpressionForInstanceMemberVariable = function (nameAST) { + var id = nameAST.valueText(); + if (id.length === 0) { + return null; + } + + var memberVariableDeclarationAST = TypeScript.ASTHelpers.getEnclosingMemberVariableDeclaration(nameAST); + if (memberVariableDeclarationAST) { + var memberVariableDecl = this.semanticInfoChain.getDeclForAST(memberVariableDeclarationAST); + if (!TypeScript.hasFlag(memberVariableDecl.flags, 16 /* Static */)) { + var constructorDecl = this.findConstructorDeclOfEnclosingType(memberVariableDecl); + + if (constructorDecl) { + var childDecls = constructorDecl.searchChildDecls(id, 68147712 /* SomeValue */); + + if (childDecls.length) { + var memberVariableSymbol = memberVariableDecl.getSymbol(); + + return this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, [memberVariableSymbol.getScopedName(constructorDecl.getSymbol()), nameAST.text()]); + } + } + } + } + return null; + }; + + PullTypeResolver.prototype.computeNameExpression = function (nameAST, context) { var id = nameAST.valueText(); if (id.length === 0) { return this.semanticInfoChain.anyTypeSymbol; @@ -43796,37 +45022,47 @@ var TypeScript; var nameSymbol = null; var enclosingDecl = this.getEnclosingDeclForAST(nameAST); - if (TypeScript.isDeclarationASTOrDeclarationNameAST(nameAST)) { + if (TypeScript.hasFlag(enclosingDecl.flags, 8388608 /* PropertyParameter */)) { + var valueDecl = enclosingDecl.getValueDecl(); + if (valueDecl && TypeScript.hasFlag(valueDecl.kind, 2048 /* Parameter */)) { + enclosingDecl = valueDecl; + } + } + + var diagnosticForInitializer = this.checkNameAsPartOfInitializerExpressionForInstanceMemberVariable(nameAST); + + if (TypeScript.ASTHelpers.isDeclarationASTOrDeclarationNameAST(nameAST)) { nameSymbol = this.semanticInfoChain.getDeclForAST(nameAST.parent).getSymbol(); } var declPath = enclosingDecl.getParentPath(); if (!nameSymbol) { - var nameSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); + var searchKind = 68147712 /* SomeValue */; + + if (!this.isInEnumDecl(enclosingDecl)) { + searchKind = searchKind & ~(67108864 /* EnumMember */); + } + + var nameSymbol = this.getSymbolFromDeclPath(id, declPath, searchKind); } - if (!nameSymbol && id === "arguments" && this.isSomeFunctionScope(declPath)) { - nameSymbol = this.cachedFunctionArgumentsSymbol(); - - this.resolveDeclaredSymbol(this.cachedIArgumentsInterfaceType(), context); - } - - if (!nameSymbol) { - nameSymbol = this.getSymbolFromDeclPath(id, declPath, 128 /* TypeAlias */); - - if (nameSymbol && !nameSymbol.isAlias()) { - nameSymbol = null; + if (id === "arguments") { + var functionScopeDecl = this.getSomeInnermostFunctionScopeDecl(declPath); + if (functionScopeDecl) { + if (!nameSymbol || !this.isFromFunctionScope(nameSymbol, functionScopeDecl)) { + nameSymbol = this.cachedFunctionArgumentsSymbol(); + this.resolveDeclaredSymbol(this.cachedIArgumentsInterfaceType(), context); + } } } if (!nameSymbol) { - if (!reportDiagnostics) { - return null; - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.text()])); - return this.getNewErrorTypeSymbol(id); - } + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.text()])); + return this.getNewErrorTypeSymbol(id); + } else if (diagnosticForInitializer) { + context.postDiagnostic(diagnosticForInitializer); + return this.getNewErrorTypeSymbol(id); } var nameDeclaration = nameSymbol.getDeclarations()[0]; @@ -43835,22 +45071,26 @@ var TypeScript; var enclosingFunctionAST = this.semanticInfoChain.getASTForDecl(nameParentDecl); var currentParameterIndex = this.getCurrentParameterIndexForFunction(nameAST, enclosingFunctionAST); - var parameterList = TypeScript.getParameterList(enclosingFunctionAST); + var parameterList = TypeScript.ASTHelpers.getParameterList(enclosingFunctionAST); if (currentParameterIndex >= 0) { - var foundMatchingParameter = false; + var matchingParameter; if (parameterList) { for (var i = 0; i <= currentParameterIndex; i++) { var candidateParameter = parameterList.parameters.nonSeparatorAt(i); if (candidateParameter && candidateParameter.identifier.valueText() === id) { - foundMatchingParameter = true; + matchingParameter = candidateParameter; + break; } } } - if (!foundMatchingParameter) { + if (!matchingParameter) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, [parameterList.parameters.nonSeparatorAt(currentParameterIndex).identifier.text(), nameAST.text()])); return this.getNewErrorTypeSymbol(id); + } else if (matchingParameter === TypeScript.ASTHelpers.getEnclosingParameterForInitializer(nameAST)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Parameter_0_cannot_be_referenced_in_its_initializer, [parameterList.parameters.nonSeparatorAt(currentParameterIndex).identifier.text()])); + return this.getNewErrorTypeSymbol(id); } } } @@ -43860,7 +45100,7 @@ var TypeScript; if (nameSymbol.isType() && nameSymbol.isAlias()) { aliasSymbol = nameSymbol; if (!this.inTypeQuery(nameAST)) { - aliasSymbol.setIsUsedAsValue(true); + aliasSymbol.setIsUsedAsValue(); } this.resolveDeclaredSymbol(nameSymbol, context); @@ -43885,7 +45125,7 @@ var TypeScript; }; PullTypeResolver.prototype.getCurrentParameterIndexForFunction = function (parameter, funcDecl) { - var parameterList = TypeScript.getParameterList(funcDecl); + var parameterList = TypeScript.ASTHelpers.getParameterList(funcDecl); if (parameterList) { while (parameter && parameter.parent) { if (parameter.parent.parent === parameterList) { @@ -43905,7 +45145,7 @@ var TypeScript; PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, expression, name, context) { var symbol = this.getSymbolForAST(dottedNameAST, context); - var foundCached = symbol != null; + var foundCached = symbol !== null; if (!foundCached || this.canTypeCheckAST(dottedNameAST, context)) { var canTypeCheckDottedNameAST = this.canTypeCheckAST(dottedNameAST, context); @@ -43918,7 +45158,7 @@ var TypeScript; this.resolveDeclaredSymbol(symbol, context); - if (symbol && (symbol.type != this.semanticInfoChain.anyTypeSymbol || symbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { + if (symbol && (symbol.type !== this.semanticInfoChain.anyTypeSymbol || symbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { this.setSymbolForAST(dottedNameAST, symbol, context); this.setSymbolForAST(name, symbol, context); } @@ -43933,17 +45173,23 @@ var TypeScript; } var lhs = this.resolveAST(expression, false, context); + return this.computeDottedNameExpressionFromLHS(lhs, expression, name, context, checkSuperPrivateAndStaticAccess); + }; + + PullTypeResolver.prototype.computeDottedNameExpressionFromLHS = function (lhs, expression, name, context, checkSuperPrivateAndStaticAccess) { + var rhsName = name.valueText(); + if (rhsName.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + var lhsType = lhs.type; if (lhs.isAlias()) { + var lhsAlias = lhs; if (!this.inTypeQuery(expression)) { - lhs.setIsUsedAsValue(true); + lhsAlias.setIsUsedAsValue(); } - lhsType = lhs.getExportAssignedTypeSymbol(); - } - - if (this.isAnyOrEquivalent(lhsType)) { - return lhsType; + lhsType = lhsAlias.getExportAssignedTypeSymbol(); } if (lhsType.isAlias()) { @@ -43958,7 +45204,7 @@ var TypeScript; if (!lhsType.isResolved) { var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); - if (potentiallySpecializedType != lhsType) { + if (potentiallySpecializedType !== lhsType) { if (!lhs.isType()) { context.setTypeInContext(lhs, potentiallySpecializedType); } @@ -43975,47 +45221,37 @@ var TypeScript; } } - if (lhsType.isTypeParameter()) { - lhsType = this.substituteUpperBoundForType(lhsType); + var originalLhsTypeForErrorReporting = lhsType; + + lhsType = this.getApparentType(lhsType).widenedType(this, expression, context); + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; } - if ((lhsType === this.semanticInfoChain.numberTypeSymbol || lhsType.isEnum()) && this.cachedNumberInterfaceType()) { - lhsType = this.cachedNumberInterfaceType(); - } else if (lhsType === this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { - lhsType = this.cachedStringInterfaceType(); - } else if (lhsType === this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { - lhsType = this.cachedBooleanInterfaceType(); - } - - var nameSymbol = this.getMemberSymbol(rhsName, 68147712 /* SomeValue */, lhsType); + var nameSymbol = this._getNamedPropertySymbolOfAugmentedType(rhsName, lhsType); if (!nameSymbol) { - if ((lhsType.getCallSignatures().length || lhsType.getConstructSignatures().length) && this.cachedFunctionInterfaceType()) { - nameSymbol = this.getMemberSymbol(rhsName, 68147712 /* SomeValue */, this.cachedFunctionInterfaceType()); - } else if (lhsType.kind === 32 /* DynamicModule */) { + if (lhsType.kind === 32 /* DynamicModule */) { var container = lhsType; var associatedInstance = container.getInstanceSymbol(); if (associatedInstance) { var instanceType = associatedInstance.type; - nameSymbol = this.getMemberSymbol(rhsName, 68147712 /* SomeValue */, instanceType); + nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, instanceType); } } else { var associatedType = lhsType.getAssociatedContainerType(); if (associatedType && !associatedType.isClass()) { - nameSymbol = this.getMemberSymbol(rhsName, 68147712 /* SomeValue */, associatedType); + nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, associatedType); } } - if (!nameSymbol && !lhsType.isPrimitive() && this.cachedObjectInterfaceType()) { - nameSymbol = this.getMemberSymbol(rhsName, 68147712 /* SomeValue */, this.cachedObjectInterfaceType()); - } - if (!nameSymbol) { var enclosingDecl = this.getEnclosingDeclForAST(expression); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [name.text(), lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [name.text(), originalLhsTypeForErrorReporting.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); return this.getNewErrorTypeSymbol(rhsName); } } @@ -44055,8 +45291,8 @@ var TypeScript; var onLeftOfDot = this.isLeftSideOfQualifiedName(nameAST); - var kindToCheckFirst = onLeftOfDot ? 164 /* SomeContainer */ : 58728539 /* SomeType */; - var kindToCheckSecond = onLeftOfDot ? 58728539 /* SomeType */ : 164 /* SomeContainer */; + var kindToCheckFirst = onLeftOfDot ? 164 /* SomeContainer */ : 58728795 /* SomeType */; + var kindToCheckSecond = onLeftOfDot ? 58728795 /* SomeType */ : 164 /* SomeContainer */; var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); @@ -44080,11 +45316,11 @@ var TypeScript; } if (typeNameSymbol.isTypeParameter()) { - if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */) && (enclosingDecl.flags & 16 /* Static */)) { + if (this.isInStaticMemberContext(enclosingDecl)) { var parentDecl = typeNameSymbol.getDeclarations()[0].getParentDecl(); - if (parentDecl.kind == 8 /* Class */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Static_methods_cannot_reference_class_type_parameters)); + if (parentDecl.kind === 8 /* Class */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Static_members_cannot_reference_class_type_parameters)); return this.getNewErrorTypeSymbol(); } } @@ -44097,6 +45333,22 @@ var TypeScript; return typeNameSymbol; }; + PullTypeResolver.prototype.isInStaticMemberContext = function (decl) { + while (decl) { + if (TypeScript.hasFlag(decl.kind, 1032192 /* SomeFunction */ | 4096 /* Property */) && TypeScript.hasFlag(decl.flags, 16 /* Static */)) { + return true; + } + + if (TypeScript.hasFlag(decl.kind, 164 /* SomeContainer */)) { + return false; + } + + decl = decl.getParentDecl(); + } + + return false; + }; + PullTypeResolver.prototype.isLeftSideOfQualifiedName = function (ast) { return ast && ast.parent && ast.parent.kind() === 121 /* QualifiedName */ && ast.parent.left === ast; }; @@ -44113,9 +45365,18 @@ var TypeScript; } if (genericTypeSymbol.isAlias()) { + if (this.inClassExtendsHeritageClause(genericTypeAST) && !this.inTypeArgumentList(genericTypeAST)) { + genericTypeSymbol.setIsUsedAsValue(); + } genericTypeSymbol = genericTypeSymbol.getExportAssignedTypeSymbol(); } + var typeParameters = genericTypeSymbol.getTypeParameters(); + if (typeParameters.length === 0) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(genericTypeAST, TypeScript.DiagnosticCode.Type_0_does_not_have_type_parameters, [genericTypeSymbol.toString()])); + return this.getNewErrorTypeSymbol(); + } + var typeArgs = []; if (genericTypeAST.typeArgumentList && genericTypeAST.typeArgumentList.typeArguments.nonSeparatorCount()) { @@ -44128,9 +45389,7 @@ var TypeScript; } } - var typeParameters = genericTypeSymbol.getTypeParameters(); - - if (typeArgs.length && typeArgs.length != typeParameters.length) { + if (typeArgs.length && typeArgs.length !== typeParameters.length) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(genericTypeAST, TypeScript.DiagnosticCode.Generic_type_0_requires_1_type_argument_s, [genericTypeSymbol.toString(), genericTypeSymbol.getTypeParameters().length])); return this.getNewErrorTypeSymbol(); } @@ -44177,7 +45436,7 @@ var TypeScript; if (typeConstraint) { if (typeConstraint.isTypeParameter()) { for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { - if (typeParameters[j] == typeConstraint) { + if (typeParameters[j] === typeConstraint) { typeConstraint = typeArgs[j]; } } @@ -44196,6 +45455,7 @@ var TypeScript; if (typeArg.inResolution || (typeArg.isTypeReference() && typeArg.referencedTypeSymbol.inResolution)) { return specializedSymbol; } + if (!this.sourceIsAssignableToTarget(typeArg, typeConstraint, genericTypeAST, context)) { var enclosingSymbol = this.getEnclosingSymbolForAST(genericTypeAST); context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(genericTypeAST, TypeScript.DiagnosticCode.Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2, [typeArg.toString(enclosingSymbol, true), typeConstraint.toString(enclosingSymbol, true), typeParameters[iArg].toString(enclosingSymbol, true)])); @@ -44227,6 +45487,10 @@ var TypeScript; return symbol; }; + PullTypeResolver.prototype.isLastNameOfModuleNameModuleReference = function (ast) { + return ast.kind() === 11 /* IdentifierName */ && ast.parent && ast.parent.kind() === 121 /* QualifiedName */ && ast.parent.right === ast && ast.parent.parent && ast.parent.parent.kind() === 246 /* ModuleNameModuleReference */; + }; + PullTypeResolver.prototype.computeQualifiedName = function (dottedNameAST, context) { var rhsName = dottedNameAST.right.valueText(); if (rhsName.length === 0) { @@ -44240,7 +45504,7 @@ var TypeScript; if (this.inClassExtendsHeritageClause(dottedNameAST) && !this.inTypeArgumentList(dottedNameAST)) { if (lhs.isAlias()) { - lhs.setIsUsedAsValue(true); + lhs.setIsUsedAsValue(); } } @@ -44254,15 +45518,20 @@ var TypeScript; var onLeftOfDot = this.isLeftSideOfQualifiedName(dottedNameAST); var isNameOfModule = dottedNameAST.parent.kind() === 130 /* ModuleDeclaration */ && dottedNameAST.parent.name === dottedNameAST; - var memberKind = (onLeftOfDot || isNameOfModule) ? 164 /* SomeContainer */ : 58728539 /* SomeType */; - var childTypeSymbol = this.getMemberSymbol(rhsName, memberKind, lhsType); + var memberKind = (onLeftOfDot || isNameOfModule) ? 164 /* SomeContainer */ : 58728795 /* SomeType */; + + var childTypeSymbol = this.getNamedPropertySymbol(rhsName, memberKind, lhsType); + + if (!childTypeSymbol && !isNameOfModule && this.isLastNameOfModuleNameModuleReference(dottedNameAST.right)) { + childTypeSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, lhsType); + } if (!childTypeSymbol && lhsType.isContainer()) { var exportedContainer = lhsType.getExportAssignedContainerSymbol(); if (exportedContainer) { - childTypeSymbol = this.getMemberSymbol(rhsName, memberKind, exportedContainer); + childTypeSymbol = this.getNamedPropertySymbol(rhsName, memberKind, exportedContainer); } } @@ -44281,7 +45550,7 @@ var TypeScript; var enclosingSymbolType = parentDecl.getSymbol().type; if (enclosingSymbolType === lhsType) { - childTypeSymbol = this.getMemberSymbol(rhsName, memberKind, lhsType); + childTypeSymbol = this.getNamedPropertySymbol(rhsName, memberKind, lhsType); } } } @@ -44316,12 +45585,12 @@ var TypeScript; if (contextualFunctionTypeSymbol) { this.resolveDeclaredSymbol(contextualFunctionTypeSymbol, context); var callSignatures = contextualFunctionTypeSymbol.getCallSignatures(); - var exactlyOneCallSignature = callSignatures && callSignatures.length == 1; + var exactlyOneCallSignature = callSignatures && callSignatures.length === 1; if (!exactlyOneCallSignature) { return false; } - var callSignatureIsGeneric = callSignatures[0].typeParameters && callSignatures[0].typeParameters.length > 0; + var callSignatureIsGeneric = callSignatures[0].getTypeParameters().length > 0; return !callSignatureIsGeneric; } @@ -44358,36 +45627,7 @@ var TypeScript; assigningFunctionSignature = context.getContextualType().getCallSignatures()[0]; } - if (parameters) { - var contextParams = []; - - if (assigningFunctionSignature) { - contextParams = assigningFunctionSignature.parameters; - } - - var contextualParametersCount = contextParams.length; - for (var i = 0, n = parameters.length; i < n; i++) { - var actualParameterIsVarArgParameter = (i === (n - 1)) && parameters.lastParameterIsRest(); - var correspondingContextualParameter = null; - var contextualParameterType = null; - - if (i < contextualParametersCount) { - correspondingContextualParameter = contextParams[i]; - } else if (contextualParametersCount && contextParams[contextualParametersCount - 1].isVarArg) { - correspondingContextualParameter = contextParams[contextualParametersCount - 1]; - } - - if (correspondingContextualParameter) { - if (correspondingContextualParameter.isVarArg === actualParameterIsVarArgParameter) { - contextualParameterType = correspondingContextualParameter.type; - } else if (correspondingContextualParameter.isVarArg) { - contextualParameterType = correspondingContextualParameter.type.getElementType(); - } - } - - this.resolveFunctionExpressionParameter(parameters.astAt(i), parameters.identifierAt(i), parameters.typeAt(i), parameters.initializerAt(i), contextualParameterType, functionDecl, context); - } - } + this.resolveAnyFunctionExpressionParameters(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, isContextuallyTyped, context); if (returnTypeAnnotation) { signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); @@ -44396,10 +45636,9 @@ var TypeScript; var returnType = assigningFunctionSignature.returnType; if (returnType) { - context.pushContextualType(returnType, context.inProvisionalResolution(), null); - + context.propagateContextualType(returnType); this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, true, functionDecl, context); - context.popContextualType(); + context.popAnyContextualType(); } else { signature.returnType = this.semanticInfoChain.anyTypeSymbol; @@ -44422,21 +45661,63 @@ var TypeScript; funcDeclSymbol.setResolved(); if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckAnyFunctionExpression(funcDeclAST, typeParameters, returnTypeAnnotation, block, bodyExpression, context); + this.typeCheckAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context); } return funcDeclSymbol; }; - PullTypeResolver.prototype.typeCheckSimpleArrowFunctionExpression = function (arrowFunction, context) { - return this.typeCheckAnyFunctionExpression(arrowFunction, null, null, arrowFunction.block, arrowFunction.expression, context); + PullTypeResolver.prototype.resolveAnyFunctionExpressionParameters = function (funcDeclAST, typeParameters, parameters, returnTypeAnnotation, isContextuallyTyped, context) { + if (!parameters) { + return; + } + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var contextParams = []; + + var assigningFunctionSignature = null; + if (isContextuallyTyped && this.shouldContextuallyTypeAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, context)) { + assigningFunctionSignature = context.getContextualType().getCallSignatures()[0]; + } + + if (assigningFunctionSignature) { + contextParams = assigningFunctionSignature.parameters; + } + + var contextualParametersCount = contextParams.length; + for (var i = 0, n = parameters.length; i < n; i++) { + var actualParameterIsVarArgParameter = (i === (n - 1)) && parameters.lastParameterIsRest(); + var correspondingContextualParameter = null; + var contextualParameterType = null; + + if (i < contextualParametersCount) { + correspondingContextualParameter = contextParams[i]; + } else if (contextualParametersCount && contextParams[contextualParametersCount - 1].isVarArg) { + correspondingContextualParameter = contextParams[contextualParametersCount - 1]; + } + + if (correspondingContextualParameter) { + if (correspondingContextualParameter.isVarArg === actualParameterIsVarArgParameter) { + contextualParameterType = correspondingContextualParameter.type; + } else if (correspondingContextualParameter.isVarArg) { + contextualParameterType = correspondingContextualParameter.type.getElementType(); + } + } + + this.resolveFunctionExpressionParameter(parameters.astAt(i), parameters.identifierAt(i), parameters.typeAt(i), parameters.initializerAt(i), contextualParameterType, functionDecl, context); + } }; - PullTypeResolver.prototype.typeCheckParenthesizedArrowFunctionExpression = function (arrowFunction, context) { - return this.typeCheckAnyFunctionExpression(arrowFunction, arrowFunction.callSignature.typeParameterList, TypeScript.getType(arrowFunction), arrowFunction.block, arrowFunction.expression, context); + PullTypeResolver.prototype.typeCheckSimpleArrowFunctionExpression = function (arrowFunction, isContextuallyTyped, context) { + return this.typeCheckAnyFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), null, arrowFunction.block, arrowFunction.expression, isContextuallyTyped, context); }; - PullTypeResolver.prototype.typeCheckAnyFunctionExpression = function (funcDeclAST, typeParameters, returnTypeAnnotation, block, bodyExpression, context) { + PullTypeResolver.prototype.typeCheckParenthesizedArrowFunctionExpression = function (arrowFunction, isContextuallyTyped, context) { + return this.typeCheckAnyFunctionExpression(arrowFunction, arrowFunction.callSignature.typeParameterList, TypeScript.ASTHelpers.parametersFromParameterList(arrowFunction.callSignature.parameterList), TypeScript.ASTHelpers.getType(arrowFunction), arrowFunction.block, arrowFunction.expression, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.typeCheckAnyFunctionExpression = function (funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context) { var _this = this; this.setTypeChecked(funcDeclAST, context); @@ -44453,27 +45734,19 @@ var TypeScript; } } - context.pushContextualType(null, context.inProvisionalResolution(), null); + this.resolveAnyFunctionExpressionParameters(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, isContextuallyTyped, context); + + context.pushNewContextualType(null); if (block) { this.resolveAST(block, false, context); } else { var bodyExpressionType = this.resolveReturnExpression(bodyExpression, functionDecl, context); this.typeCheckReturnExpression(bodyExpression, bodyExpressionType, functionDecl, context); } - context.popContextualType(); - var hasReturn = (functionDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; + context.popAnyContextualType(); - if (block && returnTypeAnnotation != null && !hasReturn) { - var isVoidOrAny = this.isAnyOrEquivalent(returnTypeSymbol) || returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol; - - if (!isVoidOrAny && !(block.statements.childCount() > 0 && block.statements.childAt(0).kind() === 157 /* ThrowStatement */)) { - var funcName = functionDecl.getDisplayName(); - funcName = funcName ? "'" + funcName + "'" : "expression"; - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Function_0_declared_a_non_void_return_type_but_has_no_return_expression, [funcName])); - } - } + this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(functionDecl, returnTypeAnnotation, returnTypeSymbol, block, context); this.validateVariableDeclarationGroups(functionDecl, context); @@ -44587,9 +45860,11 @@ var TypeScript; var current = ast; while (current) { switch (current.kind()) { - case 137 /* ConstructorDeclaration */: - var constructorDecl = current; - return previous === constructorDecl.parameterList; + case 142 /* CallSignature */: + var callSignature = current; + if (previous === callSignature.parameterList && callSignature.parent.kind() === 137 /* ConstructorDeclaration */) { + return true; + } case 131 /* ClassDeclaration */: case 130 /* ModuleDeclaration */: @@ -44602,6 +45877,13 @@ var TypeScript; return false; }; + PullTypeResolver.prototype.isFunctionAccessorOrNonArrowFunctionExpression = function (decl) { + if (decl.kind === 262144 /* GetAccessor */ || decl.kind === 524288 /* SetAccessor */) { + return true; + } + + return this.isFunctionOrNonArrowFunctionExpression(decl); + }; PullTypeResolver.prototype.isFunctionOrNonArrowFunctionExpression = function (decl) { if (decl.kind === 16384 /* Function */) { @@ -44622,7 +45904,7 @@ var TypeScript; } for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { - if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { + if (this.isFunctionAccessorOrNonArrowFunctionExpression(currentDecl)) { return; } else if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { if (currentDecl.getParentDecl() === null) { @@ -44631,6 +45913,9 @@ var TypeScript; context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_within_module_bodies)); return; } + } else if (currentDecl.kind === 64 /* Enum */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_current_location)); + return; } else if (currentDecl.kind === 32768 /* ConstructorMethod */) { if (this.inArgumentListOfSuperInvocation(thisExpression) && this.superCallMustBeFirstStatementInConstructor(currentDecl)) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_current_location)); @@ -44745,29 +46030,22 @@ var TypeScript; return; } } - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class)); return; } else { - for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { - if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { - break; - } else if (currentDecl.kind === 32768 /* ConstructorMethod */) { - var classDecl = currentDecl.getParentDecl(); - - if (!this.enclosingClassIsDerived(classDecl)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.super_cannot_be_referenced_in_non_derived_classes)); - return; - } else if (this.inConstructorParameterList(ast)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.super_cannot_be_referenced_in_constructor_arguments)); - return; - } + if (enclosingDecl.kind === 32768 /* ConstructorMethod */) { + var classDecl = enclosingDecl.getParentDecl(); + if (!this.enclosingClassIsDerived(classDecl)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.super_cannot_be_referenced_in_non_derived_classes)); + return; + } else if (this.inConstructorParameterList(ast)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.super_cannot_be_referenced_in_constructor_arguments)); return; } + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors)); } - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors)); } }; @@ -44776,17 +46054,18 @@ var TypeScript; }; PullTypeResolver.prototype.resolveFunctionPropertyAssignment = function (funcProp, isContextuallyTyped, context) { - return this.resolveAnyFunctionExpression(funcProp, funcProp.callSignature.typeParameterList, TypeScript.Parameters.fromParameterList(funcProp.callSignature.parameterList), TypeScript.getType(funcProp), funcProp.block, null, isContextuallyTyped, context); + return this.resolveAnyFunctionExpression(funcProp, funcProp.callSignature.typeParameterList, TypeScript.ASTHelpers.parametersFromParameterList(funcProp.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcProp), funcProp.block, null, isContextuallyTyped, context); }; PullTypeResolver.prototype.typeCheckFunctionPropertyAssignment = function (funcProp, isContextuallyTyped, context) { - this.typeCheckAnyFunctionExpression(funcProp, funcProp.callSignature.typeParameterList, TypeScript.getType(funcProp), funcProp.block, null, context); + this.typeCheckAnyFunctionExpression(funcProp, funcProp.callSignature.typeParameterList, TypeScript.ASTHelpers.parametersFromParameterList(funcProp.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcProp), funcProp.block, null, isContextuallyTyped, context); }; PullTypeResolver.prototype.resolveObjectLiteralExpression = function (expressionAST, isContextuallyTyped, context, additionalResults) { var symbol = this.getSymbolForAST(expressionAST, context); + var hasResolvedSymbol = symbol && symbol.isResolved; - if (!symbol || additionalResults || this.canTypeCheckAST(expressionAST, context)) { + if (!hasResolvedSymbol || additionalResults || this.canTypeCheckAST(expressionAST, context)) { if (this.canTypeCheckAST(expressionAST, context)) { this.setTypeChecked(expressionAST, context); } @@ -44810,7 +46089,7 @@ var TypeScript; var decl = this.semanticInfoChain.getDeclForAST(propertyAssignment); TypeScript.Debug.assert(decl); - if (propertyAssignment.kind() == 240 /* SimplePropertyAssignment */) { + if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { if (!isUsingExistingSymbol) { memberSymbol = new TypeScript.PullSymbol(assignmentText.memberName, 4096 /* Property */); memberSymbol.addDeclaration(decl); @@ -44826,8 +46105,9 @@ var TypeScript; } if (!isUsingExistingSymbol && !isAccessor) { - if (objectLiteralTypeSymbol.findMember(memberSymbol.name, true)) { - pullTypeContext.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(propertyAssignment, TypeScript.DiagnosticCode.Duplicate_identifier_0, [assignmentText.actualText])); + var existingMember = objectLiteralTypeSymbol.findMember(memberSymbol.name, true); + if (existingMember) { + pullTypeContext.postDiagnostic(this.semanticInfoChain.duplicateIdentifierDiagnosticFromAST(propertyAssignment, assignmentText.actualText, existingMember.getDeclarations()[0].ast())); } objectLiteralTypeSymbol.addMember(memberSymbol); @@ -44848,9 +46128,10 @@ var TypeScript; var id = this.getPropertyAssignmentName(propertyAssignment); var memberSymbol = boundMemberSymbols[i]; + var contextualMemberType = null; if (objectLiteralContextualType) { - assigningSymbol = this.getMemberSymbol(memberSymbol.name, 68147712 /* SomeValue */, objectLiteralContextualType); + assigningSymbol = this.getNamedPropertySymbol(memberSymbol.name, 68147712 /* SomeValue */, objectLiteralContextualType); if (!assigningSymbol) { if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { @@ -44863,8 +46144,8 @@ var TypeScript; if (assigningSymbol) { this.resolveDeclaredSymbol(assigningSymbol, pullTypeContext); - var contextualMemberType = assigningSymbol.kind === 4194304 /* IndexSignature */ ? assigningSymbol.returnType : assigningSymbol.type; - pullTypeContext.pushContextualType(contextualMemberType, pullTypeContext.inProvisionalResolution(), null); + contextualMemberType = assigningSymbol.kind === 4194304 /* IndexSignature */ ? assigningSymbol.returnType : assigningSymbol.type; + pullTypeContext.propagateContextualType(contextualMemberType); acceptedContextualType = true; @@ -44874,32 +46155,31 @@ var TypeScript; } } - var propertySymbol = this.resolveAST(propertyAssignment, contextualMemberType != null, pullTypeContext); - var memberExpr = this.widenType(propertySymbol.type, propertyAssignment, pullTypeContext); + var memberSymbolType = this.resolveAST(propertyAssignment, contextualMemberType !== null, pullTypeContext).type; - if (memberExpr.type) { - if (memberExpr.type.isGeneric()) { + if (memberSymbolType) { + if (memberSymbolType.isGeneric()) { objectLiteralTypeSymbol.setHasGenericMember(); } if (stringIndexerSignature) { - allMemberTypes.push(memberExpr.type); + allMemberTypes.push(memberSymbolType); } if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { - allNumericMemberTypes.push(memberExpr.type); + allNumericMemberTypes.push(memberSymbolType); } } if (acceptedContextualType) { - pullTypeContext.popContextualType(); + pullTypeContext.popAnyContextualType(); } var isAccessor = propertyAssignment.kind() === 140 /* SetAccessor */ || propertyAssignment.kind() === 139 /* GetAccessor */; - if (!isUsingExistingSymbol) { + if (!memberSymbol.isResolved) { if (isAccessor) { - this.setSymbolForAST(id, memberExpr, pullTypeContext); + this.setSymbolForAST(id, memberSymbolType, pullTypeContext); } else { - pullTypeContext.setTypeInContext(memberSymbol, memberExpr.type); + pullTypeContext.setTypeInContext(memberSymbol, memberSymbolType); memberSymbol.setResolved(); this.setSymbolForAST(id, memberSymbol, pullTypeContext); @@ -44916,7 +46196,7 @@ var TypeScript; var isUsingExistingSymbol = !!typeSymbol; if (!typeSymbol) { - typeSymbol = new TypeScript.PullTypeSymbol("", 16 /* Interface */); + typeSymbol = new TypeScript.PullTypeSymbol("", 256 /* ObjectLiteral */); typeSymbol.addDeclaration(objectLitDecl); this.setSymbolForAST(objectLitAST, typeSymbol, context); objectLitDecl.setSymbol(typeSymbol); @@ -44936,17 +46216,18 @@ var TypeScript; var allNumericMemberTypes = null; if (contextualType) { - var indexSignatures = this.getBothKindsOfIndexSignatures(contextualType, context); + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); stringIndexerSignature = indexSignatures.stringSignature; numericIndexerSignature = indexSignatures.numericSignature; + var inInferentialTyping = context.isInferentiallyTyping(); if (stringIndexerSignature) { - allMemberTypes = [stringIndexerSignature.returnType]; + allMemberTypes = inInferentialTyping ? [] : [stringIndexerSignature.returnType]; } if (numericIndexerSignature) { - allNumericMemberTypes = [numericIndexerSignature.returnType]; + allNumericMemberTypes = inInferentialTyping ? [] : [numericIndexerSignature.returnType]; } } @@ -44994,8 +46275,8 @@ var TypeScript; } }; var decl = objectLiteralSymbol.getDeclarations()[0]; - var indexerReturnType = this.widenType(this.findBestCommonType(typeCollection, context)); - if (indexerReturnType == contextualIndexSignature.returnType) { + var indexerReturnType = this.findBestCommonType(typeCollection, context).widenedType(this, null, context); + if (indexerReturnType === contextualIndexSignature.returnType) { objectLiteralSymbol.addIndexSignature(contextualIndexSignature); } else { this.semanticInfoChain.addSyntheticIndexSignature(decl, objectLiteralSymbol, this.getASTForDecl(decl), contextualIndexSignature.parameters[0].name, contextualIndexSignature.parameters[0].type, indexerReturnType); @@ -45030,7 +46311,7 @@ var TypeScript; this.resolveDeclaredSymbol(contextualType, context); if (contextualType) { - var indexSignatures = this.getBothKindsOfIndexSignatures(contextualType, context); + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); if (indexSignatures.numericSignature) { contextualElementType = indexSignatures.numericSignature.returnType; } @@ -45039,7 +46320,7 @@ var TypeScript; if (elements) { if (contextualElementType) { - context.pushContextualType(contextualElementType, context.inProvisionalResolution(), null); + context.propagateContextualType(contextualElementType); } for (var i = 0, n = elements.nonSeparatorCount(); i < n; i++) { @@ -45047,7 +46328,7 @@ var TypeScript; } if (contextualElementType) { - context.popContextualType(); + context.popAnyContextualType(); } } @@ -45055,7 +46336,8 @@ var TypeScript; elementType = elementTypes[0]; } var collection; - if (contextualElementType) { + + if (contextualElementType && !context.isInferentiallyTyping()) { if (!elementType) { elementType = contextualElementType; } @@ -45085,19 +46367,7 @@ var TypeScript; elementType = this.semanticInfoChain.undefinedTypeSymbol; } - var arraySymbol = elementType.getArrayType(); - - if (!arraySymbol) { - arraySymbol = this.createInstantiatedType(this.cachedArrayInterfaceType(), [elementType]); - - if (!arraySymbol) { - arraySymbol = this.semanticInfoChain.anyTypeSymbol; - } - - elementType.setArrayType(arraySymbol); - } - - return arraySymbol; + return this.getArrayType(elementType); }; PullTypeResolver.prototype.resolveElementAccessExpression = function (callEx, context) { @@ -45121,6 +46391,8 @@ var TypeScript; var targetTypeSymbol = targetSymbol.type; + targetTypeSymbol = this.getApparentType(targetTypeSymbol); + if (this.isAnyOrEquivalent(targetTypeSymbol)) { return { symbol: targetTypeSymbol }; } @@ -45136,7 +46408,7 @@ var TypeScript; if (callEx.argumentExpression.kind() === 14 /* StringLiteral */ || callEx.argumentExpression.kind() === 13 /* NumericLiteral */) { var memberName = callEx.argumentExpression.kind() === 14 /* StringLiteral */ ? TypeScript.stripStartAndEndQuotes(callEx.argumentExpression.text()) : callEx.argumentExpression.valueText(); - var member = this.getMemberSymbol(memberName, 68147712 /* SomeValue */, targetTypeSymbol); + var member = this._getNamedPropertySymbolOfAugmentedType(memberName, targetTypeSymbol); if (member) { this.resolveDeclaredSymbol(member, context); @@ -45145,11 +46417,7 @@ var TypeScript; } } - if (targetTypeSymbol == this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { - targetTypeSymbol = this.cachedStringInterfaceType(); - } - - var signatures = this.getBothKindsOfIndexSignatures(targetTypeSymbol, context); + var signatures = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(targetTypeSymbol, context); var stringSignature = signatures.stringSignature; var numberSignature = signatures.numericSignature; @@ -45159,6 +46427,9 @@ var TypeScript; } else if (stringSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol || indexType === this.semanticInfoChain.stringTypeSymbol)) { return { symbol: stringSignature.returnType || this.semanticInfoChain.anyTypeSymbol }; } else if (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol || indexType === this.semanticInfoChain.stringTypeSymbol) { + if (this.compilationSettings.noImplicitAny()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(callEx.argumentExpression, TypeScript.DiagnosticCode.Index_signature_of_object_type_implicitly_has_an_any_type)); + } return { symbol: this.semanticInfoChain.anyTypeSymbol }; } else { return { @@ -45168,8 +46439,16 @@ var TypeScript; } }; - PullTypeResolver.prototype.getBothKindsOfIndexSignatures = function (enclosingType, context) { - var signatures = enclosingType.getIndexSignatures(); + PullTypeResolver.prototype.getBothKindsOfIndexSignaturesIncludingAugmentedType = function (enclosingType, context) { + return this._getBothKindsOfIndexSignatures(enclosingType, context, true); + }; + + PullTypeResolver.prototype.getBothKindsOfIndexSignaturesExcludingAugmentedType = function (enclosingType, context) { + return this._getBothKindsOfIndexSignatures(enclosingType, context, false); + }; + + PullTypeResolver.prototype._getBothKindsOfIndexSignatures = function (enclosingType, context, includeAugmentedType) { + var signatures = includeAugmentedType ? enclosingType.getIndexSignaturesOfAugmentedType(this, this.cachedFunctionInterfaceType(), this.cachedObjectInterfaceType()) : enclosingType.getIndexSignatures(); var stringSignature = null; var numberSignature = null; @@ -45208,6 +46487,27 @@ var TypeScript; }; }; + PullTypeResolver.prototype._addUnhiddenSignaturesFromBaseType = function (derivedTypeSignatures, baseTypeSignatures, signaturesBeingAggregated) { + var _this = this; + if (!derivedTypeSignatures) { + signaturesBeingAggregated.push.apply(signaturesBeingAggregated, baseTypeSignatures); + return; + } + + var context = new TypeScript.PullTypeResolutionContext(this); + for (var i = 0; i < baseTypeSignatures.length; i++) { + var baseSignature = baseTypeSignatures[i]; + + var signatureIsHidden = TypeScript.ArrayUtilities.any(derivedTypeSignatures, function (sig) { + return _this.signaturesAreIdenticalWithNewEnclosingTypes(baseSignature, sig, context, false); + }); + + if (!signatureIsHidden) { + signaturesBeingAggregated.push(baseSignature); + } + } + }; + PullTypeResolver.prototype.resolveBinaryAdditionOperation = function (binaryExpression, context) { var lhsExpression = this.resolveAST(binaryExpression.left, false, context); var lhsType = lhsExpression.type; @@ -45215,22 +46515,23 @@ var TypeScript; if (TypeScript.PullHelpers.symbolIsEnum(lhsType)) { lhsType = this.semanticInfoChain.numberTypeSymbol; - } else if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { - if (rhsType != this.semanticInfoChain.nullTypeSymbol && rhsType != this.semanticInfoChain.undefinedTypeSymbol) { - lhsType = rhsType; - } else { - lhsType = this.semanticInfoChain.anyTypeSymbol; - } } if (TypeScript.PullHelpers.symbolIsEnum(rhsType)) { rhsType = this.semanticInfoChain.numberTypeSymbol; - } else if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { - if (lhsType != this.semanticInfoChain.nullTypeSymbol && lhsType != this.semanticInfoChain.undefinedTypeSymbol) { - rhsType = lhsType; + } + + var isLhsTypeNullOrUndefined = lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol; + var isRhsTypeNullOrUndefined = rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol; + + if (isLhsTypeNullOrUndefined) { + if (isRhsTypeNullOrUndefined) { + lhsType = rhsType = this.semanticInfoChain.anyTypeSymbol; } else { - rhsType = this.semanticInfoChain.anyTypeSymbol; + lhsType = rhsType; } + } else if (isRhsTypeNullOrUndefined) { + rhsType = lhsType; } var exprType = null; @@ -45310,13 +46611,13 @@ var TypeScript; var leftType = this.resolveAST(binex.left, isContextuallyTyped, context).type; var rightType = this.resolveAST(binex.right, isContextuallyTyped, context).type; - return this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); + return context.isInferentiallyTyping() ? this.bestCommonTypeOfTwoTypes(leftType, rightType, context) : this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); } else { var leftType = this.resolveAST(binex.left, false, context).type; - context.pushContextualType(leftType, context.inProvisionalResolution(), null); + context.pushNewContextualType(leftType); var rightType = this.resolveAST(binex.right, true, context).type; - context.popContextualType(); + context.popAnyContextualType(); return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); } @@ -45333,7 +46634,7 @@ var TypeScript; }; PullTypeResolver.prototype.computeTypeOfConditionalExpression = function (leftType, rightType, isContextuallyTyped, context) { - if (isContextuallyTyped) { + if (isContextuallyTyped && !context.isInferentiallyTyping()) { var contextualType = context.getContextualType(); return this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); } else { @@ -45373,11 +46674,11 @@ var TypeScript; PullTypeResolver.prototype.conditionExpressionTypesAreValid = function (leftType, rightType, expressionType, isContextuallyTyped, context) { if (isContextuallyTyped) { var contextualType = context.getContextualType(); - if (this.typesAreIdentical(expressionType, leftType) || this.typesAreIdentical(expressionType, rightType) || this.typesAreIdentical(expressionType, contextualType)) { + if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context) || this.typesAreIdentical(expressionType, contextualType, context)) { return true; } } else { - if (this.typesAreIdentical(expressionType, leftType) || this.typesAreIdentical(expressionType, rightType)) { + if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context)) { return true; } } @@ -45414,7 +46715,7 @@ var TypeScript; if (this.canTypeCheckAST(callEx, context)) { this.setTypeChecked(callEx, context); } - if (symbol != this.semanticInfoChain.anyTypeSymbol) { + if (symbol !== this.semanticInfoChain.anyTypeSymbol) { this.setSymbolForAST(callEx, symbol, context); } this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); @@ -45424,7 +46725,7 @@ var TypeScript; } var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (additionalResults && (callResolutionData != additionalResults)) { + if (additionalResults && (callResolutionData !== additionalResults)) { additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; additionalResults.candidateSignature = callResolutionData.candidateSignature; additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; @@ -45446,13 +46747,13 @@ var TypeScript; for (var i = 0; i < len; i++) { var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); + context.pushNewContextualType(contextualType); } - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType != null, context); + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); if (contextualType) { - context.popContextualType(); + context.popAnyContextualType(); contextualType = null; } } @@ -45500,12 +46801,11 @@ var TypeScript; var signatures = isSuperCall ? targetTypeSymbol.getConstructSignatures() : targetTypeSymbol.getCallSignatures(); - if (!signatures.length && (targetTypeSymbol.kind == 33554432 /* ConstructorType */)) { + if (!signatures.length && (targetTypeSymbol.kind === 33554432 /* ConstructorType */)) { this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, [targetTypeSymbol.toString()]), additionalResults, context); } - var typeArgs = null; - var typeReplacementMap = null; + var explicitTypeArgs = null; var couldNotFindGenericOverload = false; var couldNotAssignToConstraint; var constraintDiagnostic = null; @@ -45513,21 +46813,19 @@ var TypeScript; var diagnostics = []; if (callEx.argumentList.typeArgumentList) { - typeArgs = []; + explicitTypeArgs = []; if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - typeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); } } - } else if (isSuperCall && targetTypeSymbol.isGeneric()) { - typeArgs = targetTypeSymbol.getTypeArguments(); } var triedToInferTypeArgs = false; var resolvedSignatures = []; - var inferredTypeArgs; + var inferredOrExplicitTypeArgs; var specializedSignature; var typeParameters; var typeConstraint = null; @@ -45539,86 +46837,61 @@ var TypeScript; couldNotAssignToConstraint = false; if (signatures[i].isGeneric() && typeParameters.length) { - if (typeArgs) { - if (typeArgs.length == typeParameters.length) { - inferredTypeArgs = typeArgs; - } else { - typeArgumentCountDiagnostic = typeArgumentCountDiagnostic || this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Signature_expected_0_type_arguments_got_1_instead, [typeParameters.length, typeArgs.length]); - continue; - } - } else if (!typeArgs && callEx.argumentList.arguments && callEx.argumentList.arguments.nonSeparatorCount()) { - inferredTypeArgs = this.inferArgumentTypesForSignature(signatures[i], new TypeScript.ArgumentInferenceContext(this, callEx.argumentList.arguments), new TypeComparisonInfo(), context); - triedToInferTypeArgs = true; - } else { - inferredTypeArgs = []; + if (isSuperCall && targetTypeSymbol.isGeneric() && !callEx.argumentList.typeArgumentList) { + explicitTypeArgs = signatures[i].returnType.getTypeArguments(); } - if (inferredTypeArgs) { - typeReplacementMap = []; - - if (inferredTypeArgs.length) { - if (inferredTypeArgs.length != typeParameters.length) { - continue; - } - - if (targetTypeReplacementMap) { - for (var symbolID in targetTypeReplacementMap) { - if (targetTypeReplacementMap.hasOwnProperty(symbolID)) { - typeReplacementMap[symbolID] = targetTypeReplacementMap[symbolID]; - } - } - } - - for (var j = 0; j < typeParameters.length; j++) { - typeReplacementMap[typeParameters[j].pullSymbolID] = inferredTypeArgs[j]; - } - for (var j = 0; j < typeParameters.length; j++) { - typeConstraint = typeParameters[j].getConstraint(); - - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var k = 0; k < typeParameters.length && k < inferredTypeArgs.length; k++) { - if (typeParameters[k] == typeConstraint) { - typeConstraint = inferredTypeArgs[k]; - } else { - typeConstraint = this.instantiateType(typeConstraint, typeReplacementMap); - } - } - } else if (typeConstraint.isGeneric()) { - typeConstraint = this.instantiateType(typeConstraint, typeReplacementMap); - } - - if (!this.sourceIsAssignableToTarget(inferredTypeArgs[j], typeConstraint, targetAST, context, null, true)) { - var enclosingSymbol = this.getEnclosingSymbolForAST(targetAST); - constraintDiagnostic = this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2, [inferredTypeArgs[j].toString(enclosingSymbol, true), typeConstraint.toString(enclosingSymbol, true), typeParameters[j].toString(enclosingSymbol, true)]); - couldNotAssignToConstraint = true; - } - - if (couldNotAssignToConstraint) { - break; - } - } - } + if (explicitTypeArgs) { + if (explicitTypeArgs.length === typeParameters.length) { + inferredOrExplicitTypeArgs = explicitTypeArgs; } else { - if (triedToInferTypeArgs) { - continue; - } - - for (var j = 0; j < typeParameters.length; j++) { - typeReplacementMap[typeParameters[j].pullSymbolID] = this.semanticInfoChain.emptyTypeSymbol; - } - } - - if (couldNotAssignToConstraint) { + typeArgumentCountDiagnostic = typeArgumentCountDiagnostic || this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Signature_expected_0_type_arguments_got_1_instead, [typeParameters.length, explicitTypeArgs.length]); continue; } + } else { + TypeScript.Debug.assert(callEx.argumentList); + var typeArgumentInferenceContext = new TypeScript.InvocationTypeArgumentInferenceContext(this, context, signatures[i], callEx.argumentList.arguments); + inferredOrExplicitTypeArgs = this.inferArgumentTypesForSignature(typeArgumentInferenceContext, new TypeComparisonInfo(), context); + triedToInferTypeArgs = true; + } - specializedSignature = this.instantiateSignature(signatures[i], typeReplacementMap, true); + TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); - if (specializedSignature) { - resolvedSignatures[resolvedSignatures.length] = specializedSignature; + var mutableTypeReplacementMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(targetTypeReplacementMap ? targetTypeReplacementMap : []); + TypeScript.PullInstantiationHelpers.updateMutableTypeParameterArgumentMap(typeParameters, inferredOrExplicitTypeArgs, mutableTypeReplacementMap); + var typeReplacementMap = mutableTypeReplacementMap.typeParameterArgumentMap; + + if (explicitTypeArgs) { + for (var j = 0; j < typeParameters.length; j++) { + typeConstraint = typeParameters[j].getConstraint(); + + if (typeConstraint) { + if (typeConstraint.isGeneric()) { + typeConstraint = this.instantiateType(typeConstraint, typeReplacementMap); + } + + if (!this.sourceIsAssignableToTarget(inferredOrExplicitTypeArgs[j], typeConstraint, targetAST, context, null, true)) { + var enclosingSymbol = this.getEnclosingSymbolForAST(targetAST); + constraintDiagnostic = this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2, [inferredOrExplicitTypeArgs[j].toString(enclosingSymbol, true), typeConstraint.toString(enclosingSymbol, true), typeParameters[j].toString(enclosingSymbol, true)]); + couldNotAssignToConstraint = true; + } + + if (couldNotAssignToConstraint) { + break; + } + } } } + + if (couldNotAssignToConstraint) { + continue; + } + + specializedSignature = this.instantiateSignature(signatures[i], typeReplacementMap); + + if (specializedSignature) { + resolvedSignatures[resolvedSignatures.length] = specializedSignature; + } } else { if (!(callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { resolvedSignatures[resolvedSignatures.length] = signatures[i]; @@ -45643,7 +46916,7 @@ var TypeScript; this.resolveAST(callEx.argumentList.arguments, false, context); if (!couldNotFindGenericOverload) { - if (this.cachedFunctionInterfaceType() && this.sourceIsSubtypeOfTarget(targetTypeSymbol, this.cachedFunctionInterfaceType(), targetAST, context)) { + if (this.cachedFunctionInterfaceType() && this.sourceIsAssignableToTarget(targetTypeSymbol, this.cachedFunctionInterfaceType(), targetAST, context)) { if (callEx.argumentList.typeArgumentList) { this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Non_generic_functions_may_not_accept_type_arguments), additionalResults, context); } @@ -45662,7 +46935,7 @@ var TypeScript; return this.getNewErrorTypeSymbol(); } - var signature = this.resolveOverloads(callEx, signatures, callEx.argumentList.typeArgumentList != null, context, diagnostics); + var signature = this.resolveOverloads(callEx, signatures, callEx.argumentList.typeArgumentList !== null, context, diagnostics); var useBeforeResolutionSignatures = signature == null; if (!signature) { @@ -45681,10 +46954,11 @@ var TypeScript; signature = signatures[0]; } - if (!signature.isGeneric() && callEx.argumentList.typeArgumentList) { + var rootSignature = signature.getRootSymbol(); + if (!rootSignature.isGeneric() && callEx.argumentList.typeArgumentList) { this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Non_generic_functions_may_not_accept_type_arguments), additionalResults, context); - } else if (signature.isGeneric() && callEx.argumentList.typeArgumentList && signature.getTypeParameters() && (callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount() != signature.getTypeParameters().length)) { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Signature_expected_0_type_arguments_got_1_instead, [signature.getTypeParameters().length, callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()]), additionalResults, context); + } else if (rootSignature.isGeneric() && callEx.argumentList.typeArgumentList && rootSignature.getTypeParameters() && (callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount() !== rootSignature.getTypeParameters().length)) { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Signature_expected_0_type_arguments_got_1_instead, [rootSignature.getTypeParameters().length, callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()]), additionalResults, context); } var returnType = isSuperCall ? this.semanticInfoChain.voidTypeSymbol : signature.returnType; @@ -45710,14 +46984,14 @@ var TypeScript; } if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); + context.pushNewContextualType(contextualType); actualParametersContextTypeSymbols[i] = contextualType; } - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType != null, context); + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); if (contextualType) { - context.popContextualType(); + context.popAnyContextualType(); contextualType = null; } } @@ -45763,7 +47037,7 @@ var TypeScript; } var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (additionalResults && (callResolutionData != additionalResults)) { + if (additionalResults && (callResolutionData !== additionalResults)) { additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; additionalResults.candidateSignature = callResolutionData.candidateSignature; additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; @@ -45785,13 +47059,13 @@ var TypeScript; for (var i = 0; i < len; i++) { var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); + context.pushNewContextualType(contextualType); } - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType != null, context); + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); if (contextualType) { - context.popContextualType(); + context.popAnyContextualType(); contextualType = null; } } @@ -45810,6 +47084,7 @@ var TypeScript; }; PullTypeResolver.prototype.computeObjectCreationExpressionSymbol = function (callEx, context, additionalResults) { + var _this = this; var returnType = null; var targetSymbol = this.resolveAST(callEx.expression, false, context); @@ -45819,8 +47094,7 @@ var TypeScript; var constructSignatures = targetTypeSymbol.getConstructSignatures(); - var typeArgs = null; - var typeReplacementMap = null; + var explicitTypeArgs = null; var usedCallSignaturesInstead = false; var couldNotAssignToConstraint; var constraintDiagnostic = null; @@ -45846,18 +47120,18 @@ var TypeScript; if (constructSignatures.length) { if (callEx.argumentList && callEx.argumentList.typeArgumentList) { - typeArgs = []; + explicitTypeArgs = []; if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - typeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); } } } if (targetTypeSymbol.isGeneric()) { var resolvedSignatures = []; - var inferredTypeArgs; + var inferredOrExplicitTypeArgs; var specializedSignature; var typeParameters; var typeConstraint = null; @@ -45870,85 +47144,59 @@ var TypeScript; if (constructSignatures[i].isGeneric()) { typeParameters = constructSignatures[i].getTypeParameters(); - if (typeArgs) { - if (typeArgs.length == typeParameters.length) { - inferredTypeArgs = typeArgs; + if (explicitTypeArgs) { + if (explicitTypeArgs.length === typeParameters.length) { + inferredOrExplicitTypeArgs = explicitTypeArgs; } else { - typeArgumentCountDiagnostic = typeArgumentCountDiagnostic || this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Signature_expected_0_type_arguments_got_1_instead, [typeParameters.length, typeArgs.length]); + typeArgumentCountDiagnostic = typeArgumentCountDiagnostic || this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Signature_expected_0_type_arguments_got_1_instead, [typeParameters.length, explicitTypeArgs.length]); continue; } - } else if (!typeArgs && callEx.argumentList && callEx.argumentList.arguments && callEx.argumentList.arguments.nonSeparatorCount()) { - inferredTypeArgs = this.inferArgumentTypesForSignature(constructSignatures[i], new TypeScript.ArgumentInferenceContext(this, callEx.argumentList.arguments), new TypeComparisonInfo(), context); + } else if (callEx.argumentList) { + var typeArgumentInferenceContext = new TypeScript.InvocationTypeArgumentInferenceContext(this, context, constructSignatures[i], callEx.argumentList.arguments); + inferredOrExplicitTypeArgs = this.inferArgumentTypesForSignature(typeArgumentInferenceContext, new TypeComparisonInfo(), context); triedToInferTypeArgs = true; } else { - inferredTypeArgs = []; + inferredOrExplicitTypeArgs = TypeScript.ArrayUtilities.select(typeParameters, function (typeParameter) { + return typeParameter.getDefaultConstraint(_this.semanticInfoChain); + }); } - if (inferredTypeArgs) { - typeReplacementMap = []; + TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); - if (inferredTypeArgs.length) { - if (inferredTypeArgs.length < typeParameters.length) { - continue; - } + var mutableTypeReplacementMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(targetTypeReplacementMap ? targetTypeReplacementMap : []); + TypeScript.PullInstantiationHelpers.updateMutableTypeParameterArgumentMap(typeParameters, inferredOrExplicitTypeArgs, mutableTypeReplacementMap); + var typeReplacementMap = mutableTypeReplacementMap.typeParameterArgumentMap; - if (targetTypeReplacementMap) { - for (var symbolID in targetTypeReplacementMap) { - if (targetTypeReplacementMap.hasOwnProperty(symbolID)) { - typeReplacementMap[symbolID] = targetTypeReplacementMap[symbolID]; - } + if (explicitTypeArgs) { + for (var j = 0; j < typeParameters.length; j++) { + typeConstraint = typeParameters[j].getConstraint(); + + if (typeConstraint) { + if (typeConstraint.isGeneric()) { + typeConstraint = this.instantiateType(typeConstraint, typeReplacementMap); } - } - for (var j = 0; j < typeParameters.length; j++) { - typeReplacementMap[typeParameters[j].pullSymbolID] = inferredTypeArgs[j]; - } - for (var j = 0; j < typeParameters.length; j++) { - typeConstraint = typeParameters[j].getConstraint(); - - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var k = 0; k < typeParameters.length && k < inferredTypeArgs.length; k++) { - if (typeParameters[k] == typeConstraint) { - typeConstraint = inferredTypeArgs[k]; - } else { - typeConstraint = this.instantiateType(typeConstraint, typeReplacementMap); - } - } - } else if (typeConstraint.isGeneric()) { - typeConstraint = this.instantiateType(typeConstraint, typeReplacementMap); - } - - if (!this.sourceIsAssignableToTarget(inferredTypeArgs[j], typeConstraint, targetAST, context, null, true)) { - var enclosingSymbol = this.getEnclosingSymbolForAST(targetAST); - constraintDiagnostic = this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2, [inferredTypeArgs[j].toString(enclosingSymbol, true), typeConstraint.toString(enclosingSymbol, true), typeParameters[j].toString(enclosingSymbol, true)]); - couldNotAssignToConstraint = true; - } - - if (couldNotAssignToConstraint) { - break; - } + if (!this.sourceIsAssignableToTarget(inferredOrExplicitTypeArgs[j], typeConstraint, targetAST, context, null, true)) { + var enclosingSymbol = this.getEnclosingSymbolForAST(targetAST); + constraintDiagnostic = this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2, [inferredOrExplicitTypeArgs[j].toString(enclosingSymbol, true), typeConstraint.toString(enclosingSymbol, true), typeParameters[j].toString(enclosingSymbol, true)]); + couldNotAssignToConstraint = true; } - } - } else { - if (triedToInferTypeArgs) { - continue; - } else { - for (var j = 0; j < typeParameters.length; j++) { - typeReplacementMap[typeParameters[j].pullSymbolID] = this.semanticInfoChain.emptyTypeSymbol; + + if (couldNotAssignToConstraint) { + break; } } } + } - if (couldNotAssignToConstraint) { - continue; - } + if (couldNotAssignToConstraint) { + continue; + } - specializedSignature = this.instantiateSignature(constructSignatures[i], typeReplacementMap, true); + specializedSignature = this.instantiateSignature(constructSignatures[i], typeReplacementMap); - if (specializedSignature) { - resolvedSignatures[resolvedSignatures.length] = specializedSignature; - } + if (specializedSignature) { + resolvedSignatures[resolvedSignatures.length] = specializedSignature; } } else { if (!(callEx.argumentList && callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { @@ -45960,7 +47208,7 @@ var TypeScript; constructSignatures = resolvedSignatures; } - var signature = this.resolveOverloads(callEx, constructSignatures, callEx.argumentList && callEx.argumentList.typeArgumentList != null, context, diagnostics); + var signature = this.resolveOverloads(callEx, constructSignatures, callEx.argumentList && callEx.argumentList.typeArgumentList !== null, context, diagnostics); additionalResults.targetSymbol = targetSymbol; additionalResults.resolvedSignatures = constructSignatures; @@ -45998,15 +47246,15 @@ var TypeScript; returnType = signature.returnType; if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { - if (typeArgs && typeArgs.length) { - returnType = this.createInstantiatedType(returnType, typeArgs); + if (explicitTypeArgs && explicitTypeArgs.length) { + returnType = this.createInstantiatedType(returnType, explicitTypeArgs); } else { returnType = this.instantiateTypeToAny(returnType, context); } } if (usedCallSignaturesInstead) { - if (returnType != this.semanticInfoChain.voidTypeSymbol) { + if (returnType !== this.semanticInfoChain.voidTypeSymbol) { this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Call_signatures_used_in_a_new_expression_must_have_a_void_return_type), additionalResults, context); return this.getNewErrorTypeSymbol(); @@ -46044,14 +47292,14 @@ var TypeScript; } if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); + context.pushNewContextualType(contextualType); actualParametersContextTypeSymbols[i] = contextualType; } - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType != null, context); + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); if (contextualType) { - context.popContextualType(); + context.popAnyContextualType(); contextualType = null; } } @@ -46080,23 +47328,18 @@ var TypeScript; return this.getNewErrorTypeSymbol(); }; - PullTypeResolver.prototype.instantiateSignatureInContext = function (signatureA, signatureB, context) { + PullTypeResolver.prototype.instantiateSignatureInContext = function (signatureAToInstantiate, contextualSignatureB, context, shouldFixContextualSignatureParameterTypes) { var typeReplacementMap = []; var inferredTypeArgs; var specializedSignature; - var typeParameters = signatureA.getTypeParameters(); + var typeParameters = signatureAToInstantiate.getTypeParameters(); var typeConstraint = null; - var fixedParameterTypes = []; + var typeArgumentInferenceContext = new TypeScript.ContextualSignatureInstantiationTypeArgumentInferenceContext(this, context, signatureAToInstantiate, contextualSignatureB, shouldFixContextualSignatureParameterTypes); + inferredTypeArgs = this.inferArgumentTypesForSignature(typeArgumentInferenceContext, new TypeComparisonInfo(), context); - for (var i = 0; i < signatureB.parameters.length; i++) { - fixedParameterTypes.push(signatureB.parameters[i].isVarArg ? signatureB.parameters[i].type.getElementType() : signatureB.parameters[i].type); - } - - inferredTypeArgs = this.inferArgumentTypesForSignature(signatureA, new TypeScript.ArgumentInferenceContext(this, fixedParameterTypes), new TypeComparisonInfo(), context); - - var functionTypeA = signatureA.functionType; - var functionTypeB = signatureB.functionType; + var functionTypeA = signatureAToInstantiate.functionType; + var functionTypeB = contextualSignatureB.functionType; var enclosingTypeParameterMap; if (functionTypeA) { @@ -46115,34 +47358,9 @@ var TypeScript; } } - for (var i = 0; i < typeParameters.length; i++) { - typeReplacementMap[typeParameters[i].pullSymbolID] = inferredTypeArgs[i]; - } - for (var i = 0; i < typeParameters.length; i++) { - typeConstraint = typeParameters[i].getConstraint(); + TypeScript.PullInstantiationHelpers.updateTypeParameterArgumentMap(typeParameters, inferredTypeArgs, typeReplacementMap); - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var j = 0; j < typeParameters.length && j < inferredTypeArgs.length; j++) { - if (typeParameters[j] == typeConstraint) { - typeConstraint = inferredTypeArgs[j]; - } - } - } else if (typeConstraint.isGeneric()) { - typeConstraint = TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, typeConstraint, typeReplacementMap); - } - - if (!this.sourceIsAssignableToTarget(inferredTypeArgs[i], typeConstraint, null, context, null, true)) { - if (this.signaturesAreIdentical(signatureA, signatureB, true)) { - return signatureA; - } else { - return null; - } - } - } - } - - return this.instantiateSignature(signatureA, typeReplacementMap, true); + return this.instantiateSignature(signatureAToInstantiate, typeReplacementMap); }; PullTypeResolver.prototype.resolveCastExpression = function (assertionExpression, context) { @@ -46158,16 +47376,21 @@ var TypeScript; PullTypeResolver.prototype.typeCheckCastExpression = function (assertionExpression, context, typeAssertionType) { this.setTypeChecked(assertionExpression, context); - context.pushContextualType(typeAssertionType, context.inProvisionalResolution(), null); + context.pushNewContextualType(typeAssertionType); var exprType = this.resolveAST(assertionExpression.expression, true, context).type; - context.popContextualType(); + context.popAnyContextualType(); this.resolveDeclaredSymbol(typeAssertionType, context); this.resolveDeclaredSymbol(exprType, context); var comparisonInfo = new TypeComparisonInfo(); - var isAssignable = this.sourceIsAssignableToTarget(typeAssertionType, exprType, assertionExpression, context, comparisonInfo) || this.sourceIsAssignableToTarget(exprType, typeAssertionType, assertionExpression, context, comparisonInfo); + var isAssignable = this.sourceIsAssignableToTarget(exprType, typeAssertionType, assertionExpression, context, comparisonInfo); + + if (!isAssignable) { + var widenedExprType = exprType.widenedType(this, assertionExpression.expression, context); + isAssignable = this.sourceIsAssignableToTarget(typeAssertionType, widenedExprType, assertionExpression, context, comparisonInfo); + } if (!isAssignable) { var enclosingSymbol = this.getEnclosingSymbolForAST(assertionExpression); @@ -46183,9 +47406,9 @@ var TypeScript; var leftExpr = this.resolveAST(binaryExpression.left, false, context); var leftType = leftExpr.type; - context.pushContextualType(leftType, context.inProvisionalResolution(), null); + context.pushNewContextualType(leftType); var rightType = this.resolveAST(binaryExpression.right, true, context).type; - context.popContextualType(); + context.popAnyContextualType(); rightType = this.getInstanceTypeForAssignment(binaryExpression.left, rightType, context); @@ -46228,30 +47451,82 @@ var TypeScript; } if (type.isArrayNamedTypeReference()) { - var elementType = this.widenType(type.getElementType(), null, context); - - if (this.compilationSettings.noImplicitAny() && ast && ast.kind() === 214 /* ArrayLiteralExpression */) { - if (elementType === this.semanticInfoChain.anyTypeSymbol && type.getElementType() !== this.semanticInfoChain.anyTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Array_Literal_implicitly_has_an_any_type_from_widening)); - } - } - - var arraySymbol = elementType.getArrayType(); - - if (!arraySymbol) { - arraySymbol = this.createInstantiatedType(this.cachedArrayInterfaceType(), [elementType]); - - if (!arraySymbol) { - arraySymbol = this.semanticInfoChain.anyTypeSymbol; - } - } - - return arraySymbol; + return this.widenArrayType(type, ast, context); + } else if (type.kind === 256 /* ObjectLiteral */) { + return this.widenObjectLiteralType(type, ast, context); } return type; }; + PullTypeResolver.prototype.widenArrayType = function (type, ast, context) { + var elementType = type.getElementType().widenedType(this, ast, context); + + if (this.compilationSettings.noImplicitAny() && ast) { + if (elementType === this.semanticInfoChain.anyTypeSymbol && type.getElementType() !== this.semanticInfoChain.anyTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Array_Literal_implicitly_has_an_any_type_from_widening)); + } + } + + return this.getArrayType(elementType); + }; + + PullTypeResolver.prototype.widenObjectLiteralType = function (type, ast, context) { + if (!this.needsToWidenObjectLiteralType(type, ast, context)) { + return type; + } + + TypeScript.Debug.assert(type.name === ""); + var newObjectTypeSymbol = new TypeScript.PullTypeSymbol(type.name, type.kind); + var declsOfObjectType = type.getDeclarations(); + TypeScript.Debug.assert(declsOfObjectType.length === 1); + newObjectTypeSymbol.addDeclaration(declsOfObjectType[0]); + var members = type.getMembers(); + + for (var i = 0; i < members.length; i++) { + var memberType = members[i].type; + + var widenedMemberType = members[i].type.widenedType(this, ast, context); + var newMember = new TypeScript.PullSymbol(members[i].name, members[i].kind); + + var declsOfMember = members[i].getDeclarations(); + + newMember.addDeclaration(declsOfMember[0]); + newMember.type = widenedMemberType; + newObjectTypeSymbol.addMember(newMember); + newMember.setResolved(); + + if (this.compilationSettings.noImplicitAny() && ast && widenedMemberType === this.semanticInfoChain.anyTypeSymbol && memberType !== this.semanticInfoChain.anyTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Object_literal_s_property_0_implicitly_has_an_any_type_from_widening, [members[i].name])); + } + } + + var indexers = type.getIndexSignatures(); + for (var i = 0; i < indexers.length; i++) { + var newIndexer = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + var parameter = indexers[i].parameters[0]; + var newParameter = new TypeScript.PullSymbol(parameter.name, parameter.kind); + newParameter.type = parameter.type; + newIndexer.addParameter(newParameter); + newIndexer.returnType = indexers[i].returnType; + newObjectTypeSymbol.addIndexSignature(newIndexer); + } + + return newObjectTypeSymbol; + }; + + PullTypeResolver.prototype.needsToWidenObjectLiteralType = function (type, ast, context) { + var members = type.getMembers(); + for (var i = 0; i < members.length; i++) { + var memberType = members[i].type; + if (memberType !== memberType.widenedType(this, ast, context)) { + return true; + } + } + + return false; + }; + PullTypeResolver.prototype.findBestCommonType = function (collection, context, comparisonInfo) { var len = collection.getLength(); @@ -46268,15 +47543,11 @@ var TypeScript; PullTypeResolver.prototype.typeIsBestCommonTypeCandidate = function (candidateType, collection, context) { for (var i = 0; i < collection.getLength(); i++) { var otherType = collection.getTypeAtIndex(i); - if (candidateType == otherType) { + if (candidateType === otherType) { continue; } - if (candidateType.isTypeParameter() && !otherType.isTypeParameter()) { - return false; - } else if (!candidateType.isTypeParameter() && otherType.isTypeParameter()) { - continue; - } else if (!this.sourceIsSubtypeOfTarget(otherType, candidateType, null, context)) { + if (!this.sourceIsSubtypeOfTarget(otherType, candidateType, null, context)) { return false; } } @@ -46284,7 +47555,7 @@ var TypeScript; return true; }; - PullTypeResolver.prototype.typesAreIdenticalInEnclosingTypes = function (t1, t2, t1EnclosingType, t2EnclosingType, val) { + PullTypeResolver.prototype.typesAreIdenticalInEnclosingTypes = function (t1, t2, context) { t1 = this.getSymbolForRelationshipCheck(t1); t2 = this.getSymbolForRelationshipCheck(t2); @@ -46293,17 +47564,22 @@ var TypeScript; } if (t1 && t2) { - var t1GenerativeTypeKind = t1EnclosingType ? t1.getGenerativeTypeClassification(t1EnclosingType) : 0 /* Unknown */; - var t2GenerativeTypeKind = t2EnclosingType ? t2.getGenerativeTypeClassification(t2EnclosingType) : 0 /* Unknown */; - if (t1GenerativeTypeKind == 3 /* InfinitelyExpanding */ || t2GenerativeTypeKind == 3 /* InfinitelyExpanding */) { - return this.infinitelyExpandingTypesAreIdentical(t1, t2); + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + return this.infinitelyExpandingTypesAreIdentical(t1, t2, context); } } - return this.typesAreIdentical(t1, t2, val); + return this.typesAreIdentical(t1, t2, context); }; - PullTypeResolver.prototype.typesAreIdentical = function (t1, t2, val) { + PullTypeResolver.prototype.typesAreIdenticalWithNewEnclosingTypes = function (t1, t2, context) { + var enclosingTypeWalkers = context.resetEnclosingTypeWalkers(); + var areTypesIdentical = this.typesAreIdentical(t1, t2, context); + context.setEnclosingTypeWalkers(enclosingTypeWalkers); + return areTypesIdentical; + }; + + PullTypeResolver.prototype.typesAreIdentical = function (t1, t2, context) { t1 = this.getSymbolForRelationshipCheck(t1); t2 = this.getSymbolForRelationshipCheck(t2); @@ -46315,12 +47591,8 @@ var TypeScript; return false; } - if (val && t1.isPrimitive() && t1.isStringConstant() && t2 === this.semanticInfoChain.stringTypeSymbol) { - return (val.kind() === 14 /* StringLiteral */) && (TypeScript.stripStartAndEndQuotes(val.text()) === TypeScript.stripStartAndEndQuotes(t1.name)); - } - - if (val && t2.isPrimitive() && t2.isStringConstant() && t2 === this.semanticInfoChain.stringTypeSymbol) { - return (val.kind() === 14 /* StringLiteral */) && (TypeScript.stripStartAndEndQuotes(val.text()) === TypeScript.stripStartAndEndQuotes(t2.name)); + if (TypeScript.hasFlag(t1.kind, 64 /* Enum */) || TypeScript.hasFlag(t2.kind, 64 /* Enum */)) { + return false; } if (t1.isPrimitive() && t1.isStringConstant() && t2.isPrimitive() && t2.isStringConstant()) { @@ -46335,7 +47607,12 @@ var TypeScript; return true; } - if (t1.isTypeParameter() != t2.isTypeParameter()) { + var isIdentical = this.identicalCache.valueAt(t1.pullSymbolID, t2.pullSymbolID); + if (isIdentical != undefined) { + return isIdentical; + } + + if (t1.isTypeParameter() !== t2.isTypeParameter()) { return false; } else if (t1.isTypeParameter()) { var t1ParentDeclaration = t1.getDeclarations()[0].getParentDecl(); @@ -46348,27 +47625,42 @@ var TypeScript; } } - var isIdentical = this.identicalCache.valueAt(t1.pullSymbolID, t2.pullSymbolID); - if (isIdentical != undefined) { - return isIdentical; - } - - if ((t1.kind & 64 /* Enum */) || (t2.kind & 64 /* Enum */)) { - return t1.getAssociatedContainerType() === t2 || t2.getAssociatedContainerType() === t1; - } - - if (t1.isPrimitive() != t2.isPrimitive()) { + if (t1.isPrimitive() !== t2.isPrimitive()) { return false; } - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, false); + this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, true); + var symbolsWhenStartedWalkingTypes = context.startWalkingTypes(t1, t2); + isIdentical = this.typesAreIdenticalWorker(t1, t2, context); + context.endWalkingTypes(symbolsWhenStartedWalkingTypes); + this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, isIdentical); + + return isIdentical; + }; + + PullTypeResolver.prototype.typesAreIdenticalWorker = function (t1, t2, context) { + if (t1.getIsSpecialized() && t2.getIsSpecialized()) { + if (TypeScript.PullHelpers.getRootType(t1) === TypeScript.PullHelpers.getRootType(t2) && TypeScript.PullHelpers.getRootType(t1).isNamedTypeSymbol()) { + var t1TypeArguments = t1.getTypeArguments(); + var t2TypeArguments = t2.getTypeArguments(); + + if (t1TypeArguments && t2TypeArguments) { + for (var i = 0; i < t1TypeArguments.length; i++) { + if (!this.typesAreIdenticalWithNewEnclosingTypes(t1TypeArguments[i], t2TypeArguments[i], context)) { + return false; + } + } + } + + return true; + } + } if (t1.hasMembers() && t2.hasMembers()) { var t1Members = t1.getAllMembers(68147712 /* SomeValue */, 0 /* all */); var t2Members = t2.getAllMembers(68147712 /* SomeValue */, 0 /* all */); - if (t1Members.length != t2Members.length) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); + if (t1Members.length !== t2Members.length) { return false; } @@ -46380,22 +47672,13 @@ var TypeScript; for (var iMember = 0; iMember < t1Members.length; iMember++) { t1MemberSymbol = t1Members[iMember]; - t2MemberSymbol = this.getMemberSymbol(t1MemberSymbol.name, 68147712 /* SomeValue */, t2); + t2MemberSymbol = this.getNamedPropertySymbol(t1MemberSymbol.name, 68147712 /* SomeValue */, t2); - if (!t2MemberSymbol || (t1MemberSymbol.isOptional != t2MemberSymbol.isOptional)) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); - return false; - } - - t1MemberType = t1MemberSymbol.type; - t2MemberType = t2MemberSymbol.type; - - if (!this.typesAreIdenticalInEnclosingTypes(t1MemberType, t2MemberType, t1, t2)) { + if (!this.propertiesAreIdentical(t1MemberSymbol, t2MemberSymbol, context)) { return false; } } } else if (t1.hasMembers() || t2.hasMembers()) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); return false; } @@ -46408,26 +47691,57 @@ var TypeScript; var t1IndexSigs = t1.getIndexSignatures(); var t2IndexSigs = t2.getIndexSignatures(); - if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs)) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); + if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs, context)) { return false; } - if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs)) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); + if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs, context)) { return false; } - if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs)) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); + if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs, context)) { return false; } - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, true); return true; }; - PullTypeResolver.prototype.signatureGroupsAreIdentical = function (sg1, sg2) { + PullTypeResolver.prototype.propertiesAreIdentical = function (propertySymbol1, propertySymbol2, context) { + if (!propertySymbol2 || (propertySymbol1.isOptional !== propertySymbol2.isOptional)) { + return false; + } + + var t1MemberSymbolIsPrivate = propertySymbol1.anyDeclHasFlag(2 /* Private */); + var t2MemberSymbolIsPrivate = propertySymbol2.anyDeclHasFlag(2 /* Private */); + + if (t1MemberSymbolIsPrivate !== t2MemberSymbolIsPrivate) { + return false; + } else if (t2MemberSymbolIsPrivate && t1MemberSymbolIsPrivate) { + var t1MemberSymbolDecl = propertySymbol1.getDeclarations()[0]; + var sourceDecl = propertySymbol2.getDeclarations()[0]; + if (t1MemberSymbolDecl !== sourceDecl) { + return false; + } + } + + var t1MemberType = propertySymbol1.type; + var t2MemberType = propertySymbol2.type; + + context.walkMemberTypes(propertySymbol1.name); + var areMemberTypesIdentical = this.typesAreIdenticalInEnclosingTypes(t1MemberType, t2MemberType, context); + context.postWalkMemberTypes(); + return areMemberTypesIdentical; + }; + + PullTypeResolver.prototype.propertiesAreIdenticalWithNewEnclosingTypes = function (type1, type2, property1, property2, context) { + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(type1, type2); + var arePropertiesIdentical = this.propertiesAreIdentical(property1, property2, context); + context.setEnclosingTypeWalkers(enclosingWalkers); + return arePropertiesIdentical; + }; + + PullTypeResolver.prototype.signatureGroupsAreIdentical = function (sg1, sg2, context) { if (sg1 === sg2) { return true; } @@ -46436,75 +47750,15 @@ var TypeScript; return false; } - if (sg1.length != sg2.length) { + if (sg1.length !== sg2.length) { return false; } - var sig1 = null; - var sig2 = null; - var sigsMatch = false; - - for (var iSig1 = 0; iSig1 < sg1.length; iSig1++) { - sig1 = sg1[iSig1]; - - for (var iSig2 = 0; iSig2 < sg2.length; iSig2++) { - sig2 = sg2[iSig2]; - - if (this.signaturesAreIdentical(sig1, sig2)) { - sigsMatch = true; - break; - } - } - - if (sigsMatch) { - sigsMatch = false; - continue; - } - - return false; - } - - return true; - }; - - PullTypeResolver.prototype.signaturesAreIdentical = function (s1, s2, includingReturnType) { - if (typeof includingReturnType === "undefined") { includingReturnType = true; } - if (s1 === s2) { - return true; - } - - if (s1.hasVarArgs != s2.hasVarArgs) { - return false; - } - - if (s1.nonOptionalParamCount != s2.nonOptionalParamCount) { - return false; - } - - if (!!(s1.typeParameters && s1.typeParameters.length) != !!(s2.typeParameters && s2.typeParameters.length)) { - return false; - } - - if (s1.typeParameters && s2.typeParameters && (s1.typeParameters.length != s2.typeParameters.length)) { - return false; - } - - if (s1.parameters.length != s2.parameters.length) { - return false; - } - - this.resolveDeclaredSymbol(s1); - this.resolveDeclaredSymbol(s2); - - var s1Params = s1.parameters; - var s2Params = s2.parameters; - - if (includingReturnType && !this.typesAreIdenticalInEnclosingTypes(s1.returnType, s2.returnType, s1.functionType, s2.functionType)) { - return false; - } - - for (var iParam = 0; iParam < s1Params.length; iParam++) { - if (!this.typesAreIdenticalInEnclosingTypes(s1Params[iParam].type, s2Params[iParam].type, s1.functionType, s2.functionType)) { + for (var i = 0; i < sg1.length; i++) { + context.walkSignatures(sg1[i].kind, i); + var areSignaturesIdentical = this.signaturesAreIdentical(sg1[i], sg2[i], context, true); + context.postWalkSignatures(); + if (!areSignaturesIdentical) { return false; } } @@ -46512,18 +47766,152 @@ var TypeScript; return true; }; - PullTypeResolver.prototype.substituteUpperBoundForType = function (type) { - if (!type || !type.isTypeParameter()) { - return type; + PullTypeResolver.prototype.typeParametersAreIdentical = function (tp1, tp2, context) { + var typeParamsAreIdentical = this.typeParametersAreIdenticalWorker(tp1, tp2, context); + + this.setTypeParameterIdentity(tp1, tp2, undefined); + + return typeParamsAreIdentical; + }; + + PullTypeResolver.prototype.typeParametersAreIdenticalWorker = function (tp1, tp2, context) { + if (!!(tp1 && tp1.length) !== !!(tp2 && tp2.length)) { + return false; } - var constraint = type.getConstraint(); - - if (constraint && (constraint != type)) { - return this.substituteUpperBoundForType(constraint); + if (tp1 && tp2 && (tp1.length !== tp2.length)) { + return false; } - return type; + if (tp1 && tp2) { + for (var i = 0; i < tp1.length; i++) { + context.walkTypeParameterConstraints(i); + var areConstraintsIdentical = this.typesAreIdentical(tp1[i].getConstraint(), tp2[i].getConstraint(), context); + context.postWalkTypeParameterConstraints(); + if (!areConstraintsIdentical) { + return false; + } + } + } + + return true; + }; + + PullTypeResolver.prototype.setTypeParameterIdentity = function (tp1, tp2, val) { + if (tp1 && tp2 && tp1.length === tp2.length) { + for (var i = 0; i < tp1.length; i++) { + this.identicalCache.setValueAt(tp1[i].pullSymbolID, tp2[i].pullSymbolID, val); + } + } + }; + + PullTypeResolver.prototype.signaturesAreIdenticalWithNewEnclosingTypes = function (s1, s2, context, includingReturnType) { + if (typeof includingReturnType === "undefined") { includingReturnType = true; } + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(s1, s2); + var areSignaturesIdentical = this.signaturesAreIdentical(s1, s2, context, includingReturnType); + context.setEnclosingTypeWalkers(enclosingWalkers); + return areSignaturesIdentical; + }; + + PullTypeResolver.prototype.signaturesAreIdentical = function (s1, s2, context, includingReturnType) { + if (typeof includingReturnType === "undefined") { includingReturnType = true; } + if (s1 === s2) { + return true; + } + + var signaturesIdentical = this.identicalCache.valueAt(s1.pullSymbolID, s2.pullSymbolID); + if (signaturesIdentical || (signaturesIdentical != undefined && includingReturnType)) { + return signaturesIdentical; + } + + var oldValue = signaturesIdentical; + this.identicalCache.setValueAt(s1.pullSymbolID, s2.pullSymbolID, true); + + signaturesIdentical = this.signaturesAreIdenticalWorker(s1, s2, context, includingReturnType); + + if (includingReturnType) { + this.identicalCache.setValueAt(s1.pullSymbolID, s2.pullSymbolID, signaturesIdentical); + } else { + this.identicalCache.setValueAt(s1.pullSymbolID, s2.pullSymbolID, oldValue); + } + + return signaturesIdentical; + }; + + PullTypeResolver.prototype.signaturesAreIdenticalWorker = function (s1, s2, context, includingReturnType) { + if (typeof includingReturnType === "undefined") { includingReturnType = true; } + if (s1.hasVarArgs !== s2.hasVarArgs) { + return false; + } + + if (s1.nonOptionalParamCount !== s2.nonOptionalParamCount) { + return false; + } + + if (s1.parameters.length !== s2.parameters.length) { + return false; + } + + var s1TypeParameters = s1.getTypeParameters(); + var s2TypeParameters = s2.getTypeParameters(); + this.setTypeParameterIdentity(s1TypeParameters, s2TypeParameters, true); + + var typeParametersParametersAndReturnTypesAreIdentical = this.signatureTypeParametersParametersAndReturnTypesAreIdentical(s1, s2, context, includingReturnType); + + this.setTypeParameterIdentity(s1TypeParameters, s2TypeParameters, undefined); + return typeParametersParametersAndReturnTypesAreIdentical; + }; + + PullTypeResolver.prototype.signatureTypeParametersParametersAndReturnTypesAreIdentical = function (s1, s2, context, includingReturnType) { + if (!this.typeParametersAreIdenticalWorker(s1.getTypeParameters(), s2.getTypeParameters(), context)) { + return false; + } + + if (includingReturnType) { + TypeScript.PullHelpers.resolveDeclaredSymbolToUseType(s1); + TypeScript.PullHelpers.resolveDeclaredSymbolToUseType(s2); + context.walkReturnTypes(); + var areReturnTypesIdentical = this.typesAreIdenticalInEnclosingTypes(s1.returnType, s2.returnType, context); + context.postWalkReturnTypes(); + if (!areReturnTypesIdentical) { + return false; + } + } + + var s1Params = s1.parameters; + var s2Params = s2.parameters; + + for (var iParam = 0; iParam < s1Params.length; iParam++) { + TypeScript.PullHelpers.resolveDeclaredSymbolToUseType(s1Params[iParam]); + TypeScript.PullHelpers.resolveDeclaredSymbolToUseType(s2Params[iParam]); + context.walkParameterTypes(iParam); + var areParameterTypesIdentical = this.typesAreIdenticalInEnclosingTypes(s1Params[iParam].type, s2Params[iParam].type, context); + context.postWalkParameterTypes(); + + if (!areParameterTypesIdentical) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.signatureReturnTypesAreIdentical = function (s1, s2, context) { + var s1TypeParameters = s1.getTypeParameters(); + var s2TypeParameters = s2.getTypeParameters(); + this.setTypeParameterIdentity(s1TypeParameters, s2TypeParameters, true); + + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(s1, s2); + context.walkReturnTypes(); + var returnTypeIsIdentical = this.typesAreIdenticalInEnclosingTypes(s1.returnType, s2.returnType, context); + + context.setEnclosingTypeWalkers(enclosingWalkers); + + this.setTypeParameterIdentity(s1TypeParameters, s2TypeParameters, undefined); + + return returnTypeIsIdentical; }; PullTypeResolver.prototype.symbolsShareDeclaration = function (symbol1, symbol2) { @@ -46531,58 +47919,7 @@ var TypeScript; var decls2 = symbol2.getDeclarations(); if (decls1.length && decls2.length) { - return decls1[0].isEqual(decls2[0]); - } - - return false; - }; - - PullTypeResolver.prototype.sourceExtendsTarget = function (source, target, context) { - if (source.isGeneric() != target.isGeneric()) { - return false; - } - - if (source.isTypeReference() && target.isTypeReference()) { - if (source.referencedTypeSymbol.hasBase(target.referencedTypeSymbol)) { - var sourceTypeArguments = source.getTypeArguments(); - var targetTypeArguments = target.getTypeArguments(); - - if (!(sourceTypeArguments && targetTypeArguments) || sourceTypeArguments.length != targetTypeArguments.length) { - return false; - } - - for (var i = 0; i < targetTypeArguments.length; i++) { - if (!this.sourceExtendsTarget(sourceTypeArguments[i], targetTypeArguments[i], context)) { - return false; - } - } - - return true; - } - } - - if (source.hasBase(target)) { - return true; - } - - if (context.isInBaseTypeResolution() && (source.kind & (16 /* Interface */ | 8 /* Class */)) && (target.kind & (16 /* Interface */ | 8 /* Class */))) { - var sourceDecls = source.getDeclarations(); - var extendsSymbol = null; - - for (var i = 0; i < sourceDecls.length; i++) { - var sourceAST = this.semanticInfoChain.getASTForDecl(sourceDecls[i]); - var extendsClause = TypeScript.getExtendsHeritageClause(sourceAST.heritageClauses); - - if (extendsClause) { - for (var j = 0; j < extendsClause.typeNames.nonSeparatorCount(); j++) { - extendsSymbol = this.semanticInfoChain.getSymbolForAST(extendsClause.typeNames.nonSeparatorAt(j)); - - if (extendsSymbol && (extendsSymbol == target || this.sourceExtendsTarget(extendsSymbol, target, context))) { - return true; - } - } - } - } + return decls1[0] === decls2[0]; } return false; @@ -46592,44 +47929,68 @@ var TypeScript; return this.sourceIsRelatableToTarget(source, target, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); }; - PullTypeResolver.prototype.sourceMembersAreSubtypeOfTargetMembers = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceMembersAreRelatableToTargetMembers(source, target, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + PullTypeResolver.prototype.sourceMembersAreAssignableToTargetMembers = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(source, target); + var areSourceMembersAreAssignableToTargetMembers = this.sourceMembersAreRelatableToTargetMembers(source, target, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.setEnclosingTypeWalkers(enclosingWalkers); + return areSourceMembersAreAssignableToTargetMembers; }; - PullTypeResolver.prototype.sourcePropertyIsSubtypeOfTargetProperty = function (source, target, sourceProp, targetProp, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + PullTypeResolver.prototype.sourcePropertyIsAssignableToTargetProperty = function (source, target, sourceProp, targetProp, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(source, target); + var isSourcePropertyIsAssignableToTargetProperty = this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.setEnclosingTypeWalkers(enclosingWalkers); + return isSourcePropertyIsAssignableToTargetProperty; }; - PullTypeResolver.prototype.sourceCallSignaturesAreSubtypeOfTargetCallSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceCallSignaturesAreRelatableToTargetCallSignatures(source, target, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + PullTypeResolver.prototype.sourceCallSignaturesAreAssignableToTargetCallSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(source, target); + var areSourceCallSignaturesAssignableToTargetCallSignatures = this.sourceCallSignaturesAreRelatableToTargetCallSignatures(source, target, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.setEnclosingTypeWalkers(enclosingWalkers); + return areSourceCallSignaturesAssignableToTargetCallSignatures; }; - PullTypeResolver.prototype.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(source, target, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + PullTypeResolver.prototype.sourceConstructSignaturesAreAssignableToTargetConstructSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(source, target); + var areSourceConstructSignaturesAssignableToTargetConstructSignatures = this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(source, target, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.setEnclosingTypeWalkers(enclosingWalkers); + return areSourceConstructSignaturesAssignableToTargetConstructSignatures; }; - PullTypeResolver.prototype.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(source, target, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + PullTypeResolver.prototype.sourceIndexSignaturesAreAssignableToTargetIndexSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(source, target); + var areSourceIndexSignaturesAssignableToTargetIndexSignatures = this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(source, target, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.setEnclosingTypeWalkers(enclosingWalkers); + return areSourceIndexSignaturesAssignableToTargetIndexSignatures; }; - PullTypeResolver.prototype.typeIsSubtypeOfFunction = function (source, ast, context) { - if (source.getCallSignatures().length || source.getConstructSignatures().length) { + PullTypeResolver.prototype.typeIsAssignableToFunction = function (source, ast, context) { + if (source.isFunctionType()) { return true; } - return this.cachedFunctionInterfaceType() && this.sourceIsSubtypeOfTarget(source, this.cachedFunctionInterfaceType(), ast, context); + return this.cachedFunctionInterfaceType() && this.sourceIsAssignableToTarget(source, this.cachedFunctionInterfaceType(), ast, context); }; - PullTypeResolver.prototype.signatureIsSubtypeOfTarget = function (s1, s2, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.signatureIsRelatableToTarget(s1, s2, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + PullTypeResolver.prototype.signatureIsAssignableToTarget = function (s1, s2, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + context.setEnclosingTypes(s1, s2); + var isSignatureIsAssignableToTarget = this.signatureIsRelatableToTarget(s1, s2, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.setEnclosingTypeWalkers(enclosingWalkers); + return isSignatureIsAssignableToTarget; }; PullTypeResolver.prototype.sourceIsAssignableToTarget = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { return this.sourceIsRelatableToTarget(source, target, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); }; - PullTypeResolver.prototype.signatureIsAssignableToTarget = function (s1, s2, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.signatureIsRelatableToTarget(s1, s2, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + PullTypeResolver.prototype.sourceIsAssignableToTargetWithNewEnclosingTypes = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + return this.sourceIsRelatableToTargetWithNewEnclosingTypes(source, target, true, this.assignableCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); }; PullTypeResolver.prototype.getSymbolForRelationshipCheck = function (symbol) { @@ -46640,7 +48001,7 @@ var TypeScript; return symbol; }; - PullTypeResolver.prototype.sourceIsRelatableToTargetInEnclosingTypes = function (source, target, sourceEnclosingType, targetEnclosingType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + PullTypeResolver.prototype.sourceIsRelatableToTargetInEnclosingTypes = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { source = this.getSymbolForRelationshipCheck(source); target = this.getSymbolForRelationshipCheck(target); @@ -46649,9 +48010,7 @@ var TypeScript; } if (source && target) { - var sourceGenerativeTypeKind = sourceEnclosingType ? source.getGenerativeTypeClassification(sourceEnclosingType) : 0 /* Unknown */; - var targetGenerativeTypeKind = targetEnclosingType ? target.getGenerativeTypeClassification(targetEnclosingType) : 0 /* Unknown */; - if (sourceGenerativeTypeKind == 3 /* InfinitelyExpanding */ || targetGenerativeTypeKind == 3 /* InfinitelyExpanding */) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { return this.infinitelyExpandingSourceTypeIsRelatableToTargetType(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); } } @@ -46659,6 +48018,27 @@ var TypeScript; return this.sourceIsRelatableToTarget(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); }; + PullTypeResolver.prototype.sourceIsRelatableToTargetWithNewEnclosingTypes = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var enclosingWalkers = context.resetEnclosingTypeWalkers(); + var isSourceRelatable = this.sourceIsRelatableToTarget(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.setEnclosingTypeWalkers(enclosingWalkers); + return isSourceRelatable; + }; + + PullTypeResolver.prototype.sourceIsRelatableToTargetInCache = function (source, target, comparisonCache, comparisonInfo) { + var isRelatable = comparisonCache.valueAt(source.pullSymbolID, target.pullSymbolID); + + if (isRelatable) { + return { isRelatable: isRelatable }; + } + + if (isRelatable != undefined && !comparisonInfo) { + return { isRelatable: isRelatable }; + } + + return null; + }; + PullTypeResolver.prototype.sourceIsRelatableToTarget = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { source = this.getSymbolForRelationshipCheck(source); target = this.getSymbolForRelationshipCheck(target); @@ -46671,25 +48051,11 @@ var TypeScript; return true; } - var sourceSubstitution = source; + var sourceApparentType = this.getApparentType(source); - if (source == this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { - this.resolveDeclaredSymbol(this.cachedStringInterfaceType(), context); - sourceSubstitution = this.cachedStringInterfaceType(); - } else if (source == this.semanticInfoChain.numberTypeSymbol && this.cachedNumberInterfaceType()) { - this.resolveDeclaredSymbol(this.cachedNumberInterfaceType(), context); - sourceSubstitution = this.cachedNumberInterfaceType(); - } else if (source == this.semanticInfoChain.booleanTypeSymbol && this.cachedBooleanInterfaceType()) { - this.resolveDeclaredSymbol(this.cachedBooleanInterfaceType(), context); - sourceSubstitution = this.cachedBooleanInterfaceType(); - } else if (TypeScript.PullHelpers.symbolIsEnum(source) && this.cachedNumberInterfaceType()) { - sourceSubstitution = this.cachedNumberInterfaceType(); - } else if (source.isTypeParameter()) { - sourceSubstitution = this.substituteUpperBoundForType(source); - } - - if (comparisonCache.valueAt(source.pullSymbolID, target.pullSymbolID) != undefined) { - return true; + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(source, target, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; } if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && target.isStringConstant()) { @@ -46704,10 +48070,10 @@ var TypeScript; if (this.isAnyOrEquivalent(target)) { return true; } + } - if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && source.isStringConstant()) { - return true; - } + if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && source.isStringConstant()) { + return true; } if (source.isPrimitive() && source.isStringConstant() && target.isPrimitive() && target.isStringConstant()) { @@ -46718,18 +48084,18 @@ var TypeScript; return true; } - if ((source === this.semanticInfoChain.nullTypeSymbol) && (target != this.semanticInfoChain.undefinedTypeSymbol && target != this.semanticInfoChain.voidTypeSymbol)) { + if ((source === this.semanticInfoChain.nullTypeSymbol) && (target !== this.semanticInfoChain.undefinedTypeSymbol && target != this.semanticInfoChain.voidTypeSymbol)) { return true; } - if (target == this.semanticInfoChain.voidTypeSymbol) { - if (source == this.semanticInfoChain.undefinedTypeSymbol || source == this.semanticInfoChain.nullTypeSymbol) { + if (target === this.semanticInfoChain.voidTypeSymbol) { + if (source === this.semanticInfoChain.undefinedTypeSymbol || source == this.semanticInfoChain.nullTypeSymbol) { return true; } return false; - } else if (source == this.semanticInfoChain.voidTypeSymbol) { - if (target == this.semanticInfoChain.anyTypeSymbol) { + } else if (source === this.semanticInfoChain.voidTypeSymbol) { + if (target === this.semanticInfoChain.anyTypeSymbol) { return true; } @@ -46753,21 +48119,20 @@ var TypeScript; } if (source.getIsSpecialized() && target.getIsSpecialized()) { - if (TypeScript.PullHelpers.getRootType(source) == TypeScript.PullHelpers.getRootType(target)) { + if (TypeScript.PullHelpers.getRootType(source) === TypeScript.PullHelpers.getRootType(target) && TypeScript.PullHelpers.getRootType(source).isNamedTypeSymbol()) { var sourceTypeArguments = source.getTypeArguments(); var targetTypeArguments = target.getTypeArguments(); if (sourceTypeArguments && targetTypeArguments) { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, false); + comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, true); for (var i = 0; i < sourceTypeArguments.length; i++) { - if (!this.sourceIsRelatableToTarget(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + if (!this.sourceIsRelatableToTargetWithNewEnclosingTypes(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, null, isComparingInstantiatedSignatures)) { break; } } - if (i == sourceTypeArguments.length) { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, true); + if (i === sourceTypeArguments.length) { return true; } else { comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); @@ -46776,57 +48141,75 @@ var TypeScript; } } - if (sourceSubstitution.isPrimitive() || target.isPrimitive()) { - return false; - } - if (target.isTypeParameter()) { - if (source.isTypeParameter() && (source === sourceSubstitution)) { - return this.typesAreIdentical(target, source); + if (source.isTypeParameter()) { + if (!source.getConstraint()) { + return this.typesAreIdentical(target, source, context); + } else { + return this.isSourceTypeParameterConstrainedToTargetTypeParameter(source, target); + } } else { if (isComparingInstantiatedSignatures) { - target = this.substituteUpperBoundForType(target); + target = target.getBaseConstraint(this.semanticInfoChain); } else { - return this.typesAreIdentical(target, sourceSubstitution); + return this.typesAreIdentical(target, sourceApparentType, context); } } } - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, false); - - if ((source.kind & 8216 /* SomeInstantiatableType */) && (target.kind & 8216 /* SomeInstantiatableType */) && this.sourceExtendsTarget(source, target, context)) { - return true; - } - - if (this.cachedObjectInterfaceType() && target === this.cachedObjectInterfaceType()) { - return true; - } - - if (this.cachedFunctionInterfaceType() && (sourceSubstitution.getCallSignatures().length || sourceSubstitution.getConstructSignatures().length) && target.hasBase(this.cachedFunctionInterfaceType())) { - return true; - } - - if (target.hasMembers() && !this.sourceMembersAreRelatableToTargetMembers(sourceSubstitution, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); - return false; - } - - if (!this.sourceCallSignaturesAreRelatableToTargetCallSignatures(sourceSubstitution, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); - return false; - } - - if (!this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(sourceSubstitution, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); - return false; - } - - if (!this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(sourceSubstitution, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); + if (sourceApparentType.isPrimitive() || target.isPrimitive()) { return false; } comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, true); + + var symbolsWhenStartedWalkingTypes = context.startWalkingTypes(sourceApparentType, target); + + var needsSourceSubstitutionUpdate = source != sourceApparentType && context.enclosingTypeWalker1._canWalkStructure() && context.enclosingTypeWalker1._getCurrentSymbol() != sourceApparentType; + if (needsSourceSubstitutionUpdate) { + context.enclosingTypeWalker1.setCurrentSymbol(sourceApparentType); + } + + var isRelatable = this.sourceIsRelatableToTargetWorker(source, target, sourceApparentType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + + if (needsSourceSubstitutionUpdate) { + context.enclosingTypeWalker1.setCurrentSymbol(source); + } + context.endWalkingTypes(symbolsWhenStartedWalkingTypes); + + comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, isRelatable); + return isRelatable; + }; + + PullTypeResolver.prototype.isSourceTypeParameterConstrainedToTargetTypeParameter = function (source, target) { + var current = source; + while (current && current.isTypeParameter()) { + if (current === target) { + return true; + } + + current = current.getConstraint(); + } + return false; + }; + + PullTypeResolver.prototype.sourceIsRelatableToTargetWorker = function (source, target, sourceSubstitution, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + if (target.hasMembers() && !this.sourceMembersAreRelatableToTargetMembers(sourceSubstitution, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + return false; + } + + if (!this.sourceCallSignaturesAreRelatableToTargetCallSignatures(sourceSubstitution, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + return false; + } + + if (!this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(sourceSubstitution, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + return false; + } + + if (!this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(sourceSubstitution, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + return false; + } + return true; }; @@ -46835,38 +48218,23 @@ var TypeScript; for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { var targetProp = targetProps[itargetProp]; - var sourceProp = this.getMemberSymbol(targetProp.name, 68147712 /* SomeValue */, source); + + var sourceProp = this._getNamedPropertySymbolOfAugmentedType(targetProp.name, source); this.resolveDeclaredSymbol(targetProp, context); var targetPropType = targetProp.type; - if (sourceProp && sourceProp.anyDeclHasFlag(16 /* Static */) && source.isClass()) { - sourceProp = null; - } - if (!sourceProp) { - if (this.cachedObjectInterfaceType()) { - sourceProp = this.getMemberSymbol(targetProp.name, 68147712 /* SomeValue */, this.cachedObjectInterfaceType()); - } - - if (!sourceProp) { - if (this.cachedFunctionInterfaceType() && (targetPropType.getCallSignatures().length || targetPropType.getConstructSignatures().length)) { - sourceProp = this.getMemberSymbol(targetProp.name, 68147712 /* SomeValue */, this.cachedFunctionInterfaceType()); - } - - if (!sourceProp) { - if (!(targetProp.isOptional)) { - if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - comparisonInfo.flags |= 2 /* RequiredPropertyIsMissing */; - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_is_missing_property_1_from_type_2, [source.toString(enclosingSymbol), targetProp.getScopedNameEx().toString(), target.toString(enclosingSymbol)])); - } - return false; - } - continue; + if (!(targetProp.isOptional)) { + if (comparisonInfo) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + comparisonInfo.flags |= 2 /* RequiredPropertyIsMissing */; + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_is_missing_property_1_from_type_2, [source.toString(enclosingSymbol), targetProp.getScopedNameEx().toString(), target.toString(enclosingSymbol)])); } + return false; } + continue; } if (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { @@ -46878,18 +48246,18 @@ var TypeScript; }; PullTypeResolver.prototype.infinitelyExpandingSourceTypeIsRelatableToTargetType = function (sourceType, targetType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var widenedTargetType = this.widenType(targetType); - var widenedSourceType = this.widenType(sourceType); + var widenedTargetType = targetType.widenedType(this, null, context); + var widenedSourceType = sourceType.widenedType(this, null, context); - if ((widenedSourceType != this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType != this.semanticInfoChain.anyTypeSymbol)) { + if ((widenedSourceType !== this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType !== this.semanticInfoChain.anyTypeSymbol)) { var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); - if (sourceTypeNamedTypeReference != targetTypeNamedTypeReference) { + if (sourceTypeNamedTypeReference !== targetTypeNamedTypeReference) { comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); if (comparisonInfo) { var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_originating_in_inifinitely_expanding_type_reference_do_not_refer_to_same_named_type, [sourceType.getScopedNameEx(enclosingSymbol).toString(), targetType.toString(enclosingSymbol)])); + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_originating_in_infinitely_expanding_type_reference_do_not_refer_to_same_named_type, [sourceType.getScopedNameEx(enclosingSymbol).toString(), targetType.toString(enclosingSymbol)])); } return false; } @@ -46902,11 +48270,11 @@ var TypeScript; return true; } - if (!(sourceTypeArguments && targetTypeArguments) || sourceTypeArguments.length != targetTypeArguments.length) { + if (!(sourceTypeArguments && targetTypeArguments) || sourceTypeArguments.length !== targetTypeArguments.length) { comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); if (comparisonInfo) { var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_originating_in_inifinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)])); + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_originating_in_infinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)])); } return false; } @@ -46915,35 +48283,41 @@ var TypeScript; if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { comparisonInfoTypeArgumentsCheck = new TypeComparisonInfo(comparisonInfo); } - for (var i = 0; i < sourceTypeArguments.length; i++) { - if (!this.sourceIsRelatableToTarget(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + var isRelatable = true; + for (var i = 0; i < sourceTypeArguments.length && isRelatable; i++) { + context.walkTypeArgument(i); + + if (!this.sourceIsRelatableToTargetInEnclosingTypes(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, comparisonInfoTypeArgumentsCheck, isComparingInstantiatedSignatures)) { + isRelatable = false; if (comparisonInfo) { var message; var enclosingSymbol = this.getEnclosingSymbolForAST(ast); if (comparisonInfoTypeArgumentsCheck && comparisonInfoTypeArgumentsCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_originating_in_inifinitely_expanding_type_reference_have_incompatible_type_arguments_NL_2, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol), comparisonInfoTypeArgumentsCheck.message]); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_originating_in_infinitely_expanding_type_reference_have_incompatible_type_arguments_NL_2, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol), comparisonInfoTypeArgumentsCheck.message]); } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_originating_in_inifinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)]); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_originating_in_infinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)]); } comparisonInfo.addMessage(message); } } + + context.postWalkTypeArgument(); } } - comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; + comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, isRelatable); + return isRelatable; }; - PullTypeResolver.prototype.infinitelyExpandingTypesAreIdentical = function (sourceType, targetType) { - var widenedTargetType = this.widenType(targetType); - var widenedSourceType = this.widenType(sourceType); + PullTypeResolver.prototype.infinitelyExpandingTypesAreIdentical = function (sourceType, targetType, context) { + var widenedTargetType = targetType.widenedType(this, null, null); + var widenedSourceType = sourceType.widenedType(this, null, null); - if ((widenedSourceType != this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType != this.semanticInfoChain.anyTypeSymbol)) { + if ((widenedSourceType !== this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType !== this.semanticInfoChain.anyTypeSymbol)) { var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); - if (sourceTypeNamedTypeReference != targetTypeNamedTypeReference) { + if (sourceTypeNamedTypeReference !== targetTypeNamedTypeReference) { this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); return false; } @@ -46956,13 +48330,17 @@ var TypeScript; return true; } - if (!(sourceTypeArguments && targetTypeArguments) || sourceTypeArguments.length != targetTypeArguments.length) { + if (!(sourceTypeArguments && targetTypeArguments) || sourceTypeArguments.length !== targetTypeArguments.length) { this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); return false; } for (var i = 0; i < sourceTypeArguments.length; i++) { - if (!this.typesAreIdentical(sourceTypeArguments[i], targetTypeArguments[i])) { + context.walkTypeArgument(i); + var areIdentical = this.typesAreIdenticalInEnclosingTypes(sourceTypeArguments[i], targetTypeArguments[i], context); + context.postWalkTypeArgument(); + + if (!areIdentical) { this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); return false; } @@ -46974,17 +48352,37 @@ var TypeScript; }; PullTypeResolver.prototype.sourcePropertyIsRelatableToTargetProperty = function (source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var _this = this; + var sourceAndTargetAreConstructors = source.isConstructor() && target.isConstructor(); + + var getNames = function (takeTypesFromPropertyContainers) { + var enclosingSymbol = _this.getEnclosingSymbolForAST(ast); + var sourceType = takeTypesFromPropertyContainers ? sourceProp.getContainer() : source; + var targetType = takeTypesFromPropertyContainers ? targetProp.getContainer() : target; + if (sourceAndTargetAreConstructors) { + sourceType = sourceType.getAssociatedContainerType(); + targetType = targetType.getAssociatedContainerType(); + } + return { + propertyName: targetProp.getScopedNameEx().toString(), + sourceTypeName: sourceType.toString(enclosingSymbol), + targetTypeName: targetType.toString(enclosingSymbol) + }; + }; + var targetPropIsPrivate = targetProp.anyDeclHasFlag(2 /* Private */); var sourcePropIsPrivate = sourceProp.anyDeclHasFlag(2 /* Private */); - if (targetPropIsPrivate != sourcePropIsPrivate) { + if (targetPropIsPrivate !== sourcePropIsPrivate) { if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + var names = getNames(true); + var code; if (targetPropIsPrivate) { - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2, [targetProp.getScopedNameEx().toString(), sourceProp.getContainer().toString(enclosingSymbol), targetProp.getContainer().toString(enclosingSymbol)])); + code = sourceAndTargetAreConstructors ? TypeScript.DiagnosticCode.Static_property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2 : TypeScript.DiagnosticCode.Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2; } else { - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2, [targetProp.getScopedNameEx().toString(), sourceProp.getContainer().toString(enclosingSymbol), targetProp.getContainer().toString(enclosingSymbol)])); + code = sourceAndTargetAreConstructors ? TypeScript.DiagnosticCode.Static_property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2 : TypeScript.DiagnosticCode.Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2; } + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(code, [names.propertyName, names.sourceTypeName, names.targetTypeName])); comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; } return false; @@ -46992,12 +48390,13 @@ var TypeScript; var targetDecl = targetProp.getDeclarations()[0]; var sourceDecl = sourceProp.getDeclarations()[0]; - if (!targetDecl.isEqual(sourceDecl)) { + if (targetDecl !== sourceDecl) { if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + var names = getNames(true); comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_0_and_1_define_property_2_as_private, [sourceProp.getContainer().toString(enclosingSymbol), targetProp.getContainer().toString(enclosingSymbol), targetProp.getScopedNameEx().toString()])); + var code = sourceAndTargetAreConstructors ? TypeScript.DiagnosticCode.Types_0_and_1_define_static_property_2_as_private : TypeScript.DiagnosticCode.Types_0_and_1_define_property_2_as_private; + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(code, [names.sourceTypeName, names.targetTypeName, names.propertyName])); } return false; @@ -47006,9 +48405,9 @@ var TypeScript; if (sourceProp.isOptional && !targetProp.isOptional) { if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + var names = getNames(true); comparisonInfo.flags |= 2 /* RequiredPropertyIsMissing */; - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Property_0_defined_as_optional_in_type_1_but_is_required_in_type_2, [targetProp.getScopedNameEx().toString(), sourceProp.getContainer().toString(enclosingSymbol), targetProp.getContainer().toString(enclosingSymbol)])); + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Property_0_defined_as_optional_in_type_1_but_is_required_in_type_2, [names.propertyName, names.sourceTypeName, names.targetTypeName])); } return false; } @@ -47018,8 +48417,9 @@ var TypeScript; var sourcePropType = sourceProp.type; var targetPropType = targetProp.type; - if (comparisonCache.valueAt(sourcePropType.pullSymbolID, targetPropType.pullSymbolID)) { - return true; + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(sourcePropType, targetPropType, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; } var comparisonInfoPropertyTypeCheck = null; @@ -47027,23 +48427,26 @@ var TypeScript; comparisonInfoPropertyTypeCheck = new TypeComparisonInfo(comparisonInfo); } - if (this.sourceIsRelatableToTargetInEnclosingTypes(sourcePropType, targetPropType, source, target, assignableTo, comparisonCache, ast, context, comparisonInfoPropertyTypeCheck, isComparingInstantiatedSignatures)) { - return true; - } + context.walkMemberTypes(targetProp.name); + var isSourcePropertyRelatableToTargetProperty = this.sourceIsRelatableToTargetInEnclosingTypes(sourcePropType, targetPropType, assignableTo, comparisonCache, ast, context, comparisonInfoPropertyTypeCheck, isComparingInstantiatedSignatures); + context.postWalkMemberTypes(); - if (comparisonInfo) { + if (!isSourcePropertyRelatableToTargetProperty && comparisonInfo) { var enclosingSymbol = this.getEnclosingSymbolForAST(ast); comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; var message; + var names = getNames(false); if (comparisonInfoPropertyTypeCheck && comparisonInfoPropertyTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_property_0_of_types_1_and_2_are_incompatible_NL_3, [targetProp.getScopedNameEx().toString(), source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoPropertyTypeCheck.message]); + var code = sourceAndTargetAreConstructors ? TypeScript.DiagnosticCode.Types_of_static_property_0_of_class_1_and_class_2_are_incompatible_NL_3 : TypeScript.DiagnosticCode.Types_of_property_0_of_types_1_and_2_are_incompatible_NL_3; + message = TypeScript.getDiagnosticMessage(code, [names.propertyName, names.sourceTypeName, names.targetTypeName, comparisonInfoPropertyTypeCheck.message]); } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_property_0_of_types_1_and_2_are_incompatible, [targetProp.getScopedNameEx().toString(), source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + var code = sourceAndTargetAreConstructors ? TypeScript.DiagnosticCode.Types_of_static_property_0_of_class_1_and_class_2_are_incompatible : TypeScript.DiagnosticCode.Types_of_property_0_of_types_1_and_2_are_incompatible; + message = TypeScript.getDiagnosticMessage(code, [names.propertyName, names.sourceTypeName, names.targetTypeName]); } comparisonInfo.addMessage(message); } - return false; + return isSourcePropertyRelatableToTargetProperty; }; PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { @@ -47056,7 +48459,7 @@ var TypeScript; } var sourceCallSigs = source.getCallSignatures(); - if (!this.signatureGroupIsRelatableToTarget(sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { + if (!this.signatureGroupIsRelatableToTarget(source, target, sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { if (comparisonInfo) { var message; var enclosingSymbol = this.getEnclosingSymbolForAST(ast); @@ -47090,7 +48493,7 @@ var TypeScript; } var sourceConstructSigs = source.getConstructSignatures(); - if (!this.signatureGroupIsRelatableToTarget(sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { + if (!this.signatureGroupIsRelatableToTarget(source, target, sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { if (comparisonInfo) { var enclosingSymbol = this.getEnclosingSymbolForAST(ast); var message; @@ -47116,12 +48519,13 @@ var TypeScript; }; PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetIndexSigs = this.getBothKindsOfIndexSignatures(target, context); + var targetIndexSigs = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(target, context); var targetStringSig = targetIndexSigs.stringSignature; var targetNumberSig = targetIndexSigs.numericSignature; if (targetStringSig || targetNumberSig) { - var sourceIndexSigs = this.getBothKindsOfIndexSignatures(source, context); + var sourceIndexSigs = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(source, context); + var enclosingTypeIndexSigs = context.getBothKindOfIndexSignatures(true, false); var sourceStringSig = sourceIndexSigs.stringSignature; var sourceNumberSig = sourceIndexSigs.numericSignature; @@ -47133,7 +48537,9 @@ var TypeScript; if (targetStringSig) { if (sourceStringSig) { - comparable = this.signatureIsAssignableToTarget(sourceStringSig, targetStringSig, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, true); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetStringSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); } else { comparable = false; } @@ -47141,9 +48547,13 @@ var TypeScript; if (comparable && targetNumberSig) { if (sourceNumberSig) { - comparable = this.signatureIsAssignableToTarget(sourceNumberSig, targetNumberSig, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, false, false); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceNumberSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); } else if (sourceStringSig) { - comparable = this.sourceIsAssignableToTarget(sourceStringSig.returnType, targetNumberSig.returnType, ast, context, comparisonInfoSignatuesTypeCheck); + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, false); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); } else { comparable = false; } @@ -47168,7 +48578,7 @@ var TypeScript; return true; }; - PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (sourceSG, targetSG, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (source, target, sourceSG, targetSG, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { if (sourceSG === targetSG) { return true; } @@ -47177,27 +48587,37 @@ var TypeScript; return false; } - var mSig = null; - var nSig = null; var foundMatch = false; var targetExcludeDefinition = targetSG.length > 1; var sourceExcludeDefinition = sourceSG.length > 1; + var sigsCompared = 0; + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo, true); + comparisonInfoSignatuesTypeCheck.message = comparisonInfo.message; + } for (var iMSig = 0; iMSig < targetSG.length; iMSig++) { - mSig = targetSG[iMSig]; + var mSig = targetSG[iMSig]; if (mSig.isStringConstantOverloadSignature() || (targetExcludeDefinition && mSig.isDefinition())) { continue; } for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { - nSig = sourceSG[iNSig]; + var nSig = sourceSG[iNSig]; if (nSig.isStringConstantOverloadSignature() || (sourceExcludeDefinition && nSig.isDefinition())) { continue; } - if (this.signatureIsRelatableToTarget(nSig, mSig, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + context.walkSignatures(nSig.kind, iNSig, iMSig); + var isSignatureRelatableToTarget = this.signatureIsRelatableToTarget(nSig, mSig, assignableTo, comparisonCache, ast, context, sigsCompared == 0 ? comparisonInfoSignatuesTypeCheck : null, isComparingInstantiatedSignatures); + context.postWalkSignatures(); + + sigsCompared++; + + if (isSignatureRelatableToTarget) { foundMatch = true; break; } @@ -47207,6 +48627,11 @@ var TypeScript; foundMatch = false; continue; } + + if (comparisonInfo && sigsCompared == 1) { + comparisonInfo.message = comparisonInfoSignatuesTypeCheck.message; + } + return false; } @@ -47214,6 +48639,19 @@ var TypeScript; }; PullTypeResolver.prototype.signatureIsRelatableToTarget = function (sourceSig, targetSig, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(sourceSig, targetSig, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; + } + + comparisonCache.setValueAt(sourceSig.pullSymbolID, targetSig.pullSymbolID, true); + var isRelatable = this.signatureIsRelatableToTargetWorker(sourceSig, targetSig, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + comparisonCache.setValueAt(sourceSig.pullSymbolID, targetSig.pullSymbolID, isRelatable); + return isRelatable; + }; + + PullTypeResolver.prototype.signatureIsRelatableToTargetWorker = function (sourceSig, targetSig, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var _this = this; var sourceParameters = sourceSig.parameters; var targetParameters = targetSig.parameters; @@ -47221,43 +48659,37 @@ var TypeScript; return false; } - var targetVarArgCount = targetSig.nonOptionalParamCount; - var sourceVarArgCount = sourceSig.nonOptionalParamCount; + var targetNonOptionalParamCount = targetSig.nonOptionalParamCount; + var sourceNonOptionalParamCount = sourceSig.nonOptionalParamCount; - if (sourceVarArgCount > targetVarArgCount) { + if (!targetSig.hasVarArgs && sourceNonOptionalParamCount > targetParameters.length) { if (comparisonInfo) { comparisonInfo.flags |= 3 /* SourceSignatureHasTooManyParameters */; - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signature_expects_0_or_fewer_parameters, [targetVarArgCount])); + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signature_expects_0_or_fewer_parameters, [targetParameters.length])); } return false; } - if (sourceSig.isGeneric()) { - var rootSourceSig = sourceSig.getRootSymbol(); - var rootTargetSig = targetSig.getRootSymbol(); - - if (comparisonCache.valueAt(rootSourceSig.pullSymbolID, rootTargetSig.pullSymbolID) != undefined) { - return true; - } - - comparisonCache.setValueAt(rootSourceSig.pullSymbolID, rootTargetSig.pullSymbolID, false); - - sourceSig = this.instantiateSignatureInContext(sourceSig, targetSig, context); - - if (!sourceSig) { - return false; - } else { - sourceParameters = sourceSig.parameters; - } + if (this.signaturesAreIdentical(sourceSig, targetSig, context)) { + return true; } - comparisonCache.setValueAt(sourceSig.pullSymbolID, targetSig.pullSymbolID, false); + if (targetSig.isGeneric()) { + targetSig = this.instantiateSignatureToAny(targetSig); + } + + if (sourceSig.isGeneric()) { + sourceSig = this.instantiateSignatureToAny(sourceSig); + } var sourceReturnType = sourceSig.returnType; var targetReturnType = targetSig.returnType; - if (targetReturnType != this.semanticInfoChain.voidTypeSymbol) { - if (!this.sourceIsRelatableToTargetInEnclosingTypes(sourceReturnType, targetReturnType, sourceSig.functionType, targetSig.functionType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + if (targetReturnType !== this.semanticInfoChain.voidTypeSymbol) { + context.walkReturnTypes(); + var returnTypesAreRelatable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceReturnType, targetReturnType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.postWalkReturnTypes(); + if (!returnTypesAreRelatable) { if (comparisonInfo) { comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; } @@ -47266,51 +48698,24 @@ var TypeScript; } } - var len = (sourceVarArgCount < targetVarArgCount && (sourceSig.hasVarArgs || (sourceParameters.length > sourceVarArgCount))) ? targetVarArgCount : sourceVarArgCount; - - if (!len) { - len = (sourceParameters.length < targetParameters.length) ? sourceParameters.length : targetParameters.length; - } - - var sourceParamType = null; - var targetParamType = null; - var sourceParamName = ""; - var targetParamName = ""; - - for (var iSource = 0, iTarget = 0; iSource < len; iSource++, iTarget++) { - if (iSource < sourceParameters.length && (!sourceSig.hasVarArgs || iSource < sourceVarArgCount)) { - sourceParamType = sourceParameters[iSource].type; - sourceParamName = sourceParameters[iSource].name; - } else if (iSource === sourceVarArgCount) { - sourceParamType = sourceParameters[iSource].type; - if (sourceParamType.isArrayNamedTypeReference()) { - sourceParamType = sourceParamType.getElementType(); - } - sourceParamName = sourceParameters[iSource].name; + return targetSig.forAllCorrespondingParameterTypesInThisAndOtherSignature(sourceSig, function (targetParamType, sourceParamType, iParam) { + context.walkParameterTypes(iParam); + var areParametersRelatable = _this.sourceIsRelatableToTargetInEnclosingTypes(sourceParamType, targetParamType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + if (!areParametersRelatable) { + context.swapEnclosingTypeWalkers(); + areParametersRelatable = _this.sourceIsRelatableToTargetInEnclosingTypes(targetParamType, sourceParamType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.swapEnclosingTypeWalkers(); } + context.postWalkParameterTypes(); - if (iTarget < targetParameters.length && !targetSig.hasVarArgs && (!targetVarArgCount || (iTarget < targetVarArgCount))) { - targetParamType = targetParameters[iTarget].type; - targetParamName = targetParameters[iTarget].name; - } else if (targetSig.hasVarArgs && iTarget === targetVarArgCount) { - targetParamType = targetParameters[iTarget].type; - - if (targetParamType.isArrayNamedTypeReference()) { - targetParamType = targetParamType.getElementType(); - } - targetParamName = targetParameters[iTarget].name; - } - - if (!(this.sourceIsRelatableToTargetInEnclosingTypes(sourceParamType, targetParamType, sourceSig.functionType, targetSig.functionType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) || this.sourceIsRelatableToTargetInEnclosingTypes(targetParamType, sourceParamType, targetSig.functionType, sourceSig.functionType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures))) { + if (!areParametersRelatable) { if (comparisonInfo) { comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; } - - return false; } - } - return true; + return areParametersRelatable; + }); }; PullTypeResolver.prototype.resolveOverloads = function (application, group, haveTypeArgumentsAtCallSite, context, diagnostics) { @@ -47324,7 +48729,8 @@ var TypeScript; return false; } - if (haveTypeArgumentsAtCallSite && !signature.isGeneric()) { + var rootSignature = signature.getRootSymbol(); + if (haveTypeArgumentsAtCallSite && !rootSignature.isGeneric()) { return false; } @@ -47423,13 +48829,13 @@ var TypeScript; return 1 /* AssignableButWithProvisionalErrors */; } else if (arg.kind() === 219 /* SimpleArrowFunctionExpression */) { var simpleArrowFunction = arg; - return this.overloadIsApplicableForAnyFunctionExpressionArgument(paramType, arg, null, TypeScript.Parameters.fromIdentifier(simpleArrowFunction.identifier), null, simpleArrowFunction.block, simpleArrowFunction.expression, argIndex, context, comparisonInfo); + return this.overloadIsApplicableForAnyFunctionExpressionArgument(paramType, arg, null, TypeScript.ASTHelpers.parametersFromIdentifier(simpleArrowFunction.identifier), null, simpleArrowFunction.block, simpleArrowFunction.expression, argIndex, context, comparisonInfo); } else if (arg.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { var arrowFunction = arg; - return this.overloadIsApplicableForAnyFunctionExpressionArgument(paramType, arg, arrowFunction.callSignature.typeParameterList, TypeScript.Parameters.fromParameterList(arrowFunction.callSignature.parameterList), TypeScript.getType(arrowFunction), arrowFunction.block, arrowFunction.expression, argIndex, context, comparisonInfo); + return this.overloadIsApplicableForAnyFunctionExpressionArgument(paramType, arg, arrowFunction.callSignature.typeParameterList, TypeScript.ASTHelpers.parametersFromParameterList(arrowFunction.callSignature.parameterList), TypeScript.ASTHelpers.getType(arrowFunction), arrowFunction.block, arrowFunction.expression, argIndex, context, comparisonInfo); } else if (arg.kind() === 222 /* FunctionExpression */) { var functionExpression = arg; - return this.overloadIsApplicableForAnyFunctionExpressionArgument(paramType, arg, functionExpression.callSignature.typeParameterList, TypeScript.Parameters.fromParameterList(functionExpression.callSignature.parameterList), TypeScript.getType(functionExpression), functionExpression.block, null, argIndex, context, comparisonInfo); + return this.overloadIsApplicableForAnyFunctionExpressionArgument(paramType, arg, functionExpression.callSignature.typeParameterList, TypeScript.ASTHelpers.parametersFromParameterList(functionExpression.callSignature.parameterList), TypeScript.ASTHelpers.getType(functionExpression), functionExpression.block, null, argIndex, context, comparisonInfo); } else if (arg.kind() === 215 /* ObjectLiteralExpression */) { return this.overloadIsApplicableForObjectLiteralArgument(paramType, arg, argIndex, context, comparisonInfo); } else if (arg.kind() === 214 /* ArrayLiteralExpression */) { @@ -47444,13 +48850,13 @@ var TypeScript; return 2 /* AssignableWithNoProvisionalErrors */; } - context.pushContextualType(paramType, true, null); + context.pushProvisionalType(paramType); var argSym = this.resolveAnyFunctionExpression(arg, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, true, context); var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - context.popContextualType(); + context.popAnyContextualType(); return applicabilityStatus; }; @@ -47460,12 +48866,12 @@ var TypeScript; return 2 /* AssignableWithNoProvisionalErrors */; } - context.pushContextualType(paramType, true, null); + context.pushProvisionalType(paramType); var argSym = this.resolveObjectLiteralExpression(arg, true, context); var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - context.popContextualType(); + context.popAnyContextualType(); return applicabilityStatus; }; @@ -47475,12 +48881,12 @@ var TypeScript; return 2 /* AssignableWithNoProvisionalErrors */; } - context.pushContextualType(paramType, true, null); + context.pushProvisionalType(paramType); var argSym = this.resolveArrayLiteralExpression(arg, true, context); var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - context.popContextualType(); + context.popAnyContextualType(); return applicabilityStatus; }; @@ -47516,92 +48922,34 @@ var TypeScript; return 0 /* NotAssignable */; }; - PullTypeResolver.prototype.inferArgumentTypesForSignature = function (signature, argContext, comparisonInfo, context) { - var cxt = null; + PullTypeResolver.prototype.inferArgumentTypesForSignature = function (argContext, comparisonInfo, context) { + var inferenceResultTypes = argContext.inferTypeArguments(); + var typeParameters = argContext.signatureBeingInferred.getTypeParameters(); + TypeScript.Debug.assert(typeParameters.length == inferenceResultTypes.length); - var parameters = signature.parameters; - var typeParameters = signature.getTypeParameters(); - - var parameterType = null; - var argCount = argContext.getInferenceArgumentCount(); - - for (var i = 0; i < typeParameters.length; i++) { - argContext.addInferenceRoot(typeParameters[i]); - } - - for (var i = 0; i < argCount; i++) { - if (i >= parameters.length) { - break; - } - - parameterType = parameters[i].type; - - if (signature.hasVarArgs && (i >= signature.nonOptionalParamCount - 1) && parameterType.isArrayNamedTypeReference()) { - parameterType = parameterType.getElementType(); - } - - var inferenceCandidates = argContext.getInferenceCandidates(); - - if (inferenceCandidates.length) { - for (var j = 0; j < inferenceCandidates.length; j++) { - argContext.resetRelationshipCache(); - var substitutions = inferenceCandidates[j]; - - context.pushContextualType(parameterType, true, substitutions); - - this.relateTypeToTypeParameters(argContext.getArgumentTypeSymbolAtIndex(i, context), parameterType, false, argContext, context); - - cxt = context.popContextualType(); - } - } else { - context.pushContextualType(parameterType, true, []); - - this.relateTypeToTypeParameters(argContext.getArgumentTypeSymbolAtIndex(i, context), parameterType, false, argContext, context); - - cxt = context.popContextualType(); - } - } - - var inferenceResults = argContext.inferArgumentTypes(this, context); - - if (inferenceResults.unfit) { - return null; - } - - var resultTypes = []; - - for (var i = 0; i < typeParameters.length; i++) { - for (var j = 0; j < inferenceResults.results.length; j++) { - if ((inferenceResults.results[j].param == typeParameters[i]) && inferenceResults.results[j].type) { - resultTypes[resultTypes.length] = inferenceResults.results[j].type; - break; + var typeReplacementMapForConstraints = null; + for (var i = 0; i < inferenceResultTypes.length; i++) { + if (typeParameters[i].getConstraint()) { + typeReplacementMapForConstraints = typeReplacementMapForConstraints || TypeScript.PullInstantiationHelpers.createTypeParameterArgumentMap(typeParameters, inferenceResultTypes); + var associatedConstraint = this.instantiateType(typeParameters[i].getConstraint(), typeReplacementMapForConstraints); + if (!this.sourceIsAssignableToTargetWithNewEnclosingTypes(inferenceResultTypes[i], associatedConstraint, null, context, null, false)) { + inferenceResultTypes[i] = associatedConstraint; } } } - if (!argCount && !resultTypes.length && typeParameters.length) { - for (var i = 0; i < typeParameters.length; i++) { - resultTypes[resultTypes.length] = this.semanticInfoChain.emptyTypeSymbol; - } - } else if (resultTypes.length < typeParameters.length) { - for (var i = resultTypes.length; i < typeParameters.length; i++) { - resultTypes[i] = this.semanticInfoChain.emptyTypeSymbol; - } - } - - var inferringAtCallExpression = argContext.argumentASTs && argContext.argumentASTs.parent && argContext.argumentASTs.parent.kind() === 226 /* ArgumentList */ && (argContext.argumentASTs.parent.parent.kind() === 213 /* InvocationExpression */ || argContext.argumentASTs.parent.parent.kind() === 216 /* ObjectCreationExpression */); - - if (inferringAtCallExpression) { - if (!this.typeParametersAreInScopeAtArgumentList(typeParameters, argContext.argumentASTs)) { - for (var i = 0; i < resultTypes.length; i++) { - if (resultTypes[i].wrapsSomeTypeParameter(argContext.candidateCache)) { - resultTypes[i] = this.semanticInfoChain.emptyTypeSymbol; + if (argContext.isInvocationInferenceContext()) { + var invocationContext = argContext; + if (!this.typeParametersAreInScopeAtArgumentList(typeParameters, invocationContext.argumentASTs)) { + for (var i = 0; i < inferenceResultTypes.length; i++) { + if (inferenceResultTypes[i].wrapsSomeTypeParameter(argContext.candidateCache)) { + inferenceResultTypes[i] = this.semanticInfoChain.anyTypeSymbol; } } } } - return resultTypes; + return inferenceResultTypes; }; PullTypeResolver.prototype.typeParametersAreInScopeAtArgumentList = function (typeParameters, args) { @@ -47610,19 +48958,23 @@ var TypeScript; return enclosingDecl.getParentPath().indexOf(typeParameterParentDecl) > -1; }; - PullTypeResolver.prototype.relateTypeToTypeParametersInEnclosingType = function (expressionType, parameterType, expressionTypeEnclosingType, parameterTypeEnclosingType, shouldFix, argContext, context) { + PullTypeResolver.prototype.relateTypeToTypeParametersInEnclosingType = function (expressionType, parameterType, argContext, context) { if (expressionType && parameterType) { - var expressionTypeGenerativeTypeClassification = expressionTypeEnclosingType ? expressionType.getGenerativeTypeClassification(expressionTypeEnclosingType) : 0 /* Unknown */; - var parameterTypeGenerativeTypeClassification = parameterTypeEnclosingType ? parameterType.getGenerativeTypeClassification(parameterTypeEnclosingType) : 0 /* Unknown */; - if (expressionTypeGenerativeTypeClassification == 3 /* InfinitelyExpanding */ || parameterTypeGenerativeTypeClassification == 3 /* InfinitelyExpanding */) { - this.relateInifinitelyExpandingTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, context); + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + this.relateInifinitelyExpandingTypeToTypeParameters(expressionType, parameterType, argContext, context); return; } } - this.relateTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, context); + this.relateTypeToTypeParameters(expressionType, parameterType, argContext, context); }; - PullTypeResolver.prototype.relateTypeToTypeParameters = function (expressionType, parameterType, shouldFix, argContext, context) { + PullTypeResolver.prototype.relateTypeToTypeParametersWithNewEnclosingTypes = function (expressionType, parameterType, argContext, context) { + var enclosingTypeWalkers = context.resetEnclosingTypeWalkers(); + this.relateTypeToTypeParameters(expressionType, parameterType, argContext, context); + context.setEnclosingTypeWalkers(enclosingTypeWalkers); + }; + + PullTypeResolver.prototype.relateTypeToTypeParameters = function (expressionType, parameterType, argContext, context) { if (!expressionType || !parameterType) { return; } @@ -47632,82 +48984,73 @@ var TypeScript; } if (parameterType.isTypeParameter()) { - argContext.addCandidateForInference(parameterType, expressionType, shouldFix); + var typeParameter = parameterType; + argContext.addCandidateForInference(typeParameter, expressionType); return; } - var parameterDeclarations = parameterType.getDeclarations(); - var expressionDeclarations = expressionType.getDeclarations(); - - if (!parameterType.isArrayNamedTypeReference() && parameterDeclarations.length && expressionDeclarations.length && !(parameterType.isTypeParameter() || expressionType.isTypeParameter()) && (parameterDeclarations[0].isEqual(expressionDeclarations[0]) || (expressionType.isGeneric() && parameterType.isGeneric() && this.sourceIsSubtypeOfTarget(this.instantiateTypeToAny(expressionType, context), this.instantiateTypeToAny(parameterType, context), null, context, null))) && expressionType.isGeneric()) { - this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, context); - } - - if (expressionType.isArrayNamedTypeReference() && parameterType.isArrayNamedTypeReference()) { - this.relateArrayTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, context); - + if (parameterType.isNamedTypeSymbol() && !parameterType.isGeneric() && !parameterType.getTypeArguments()) { return; } - this.relateObjectTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, context); - }; - - PullTypeResolver.prototype.relateTypeArgumentsOfTypeToTypeParameters = function (expressionType, parameterType, shouldFix, argContext, context) { - var typeParameters = parameterType.getTypeArgumentsOrTypeParameters(); - var typeArguments = expressionType.getTypeArguments(); - - if (!typeArguments) { - typeParameters = parameterType.getTypeArguments(); - typeArguments = expressionType.getTypeArgumentsOrTypeParameters(); - } - - if (typeParameters && typeArguments && typeParameters.length === typeArguments.length) { - for (var i = 0; i < typeParameters.length; i++) { - if (typeArguments[i] != typeParameters[i]) { - this.relateTypeToTypeParameters(typeArguments[i], typeParameters[i], true, argContext, context); - } - } + if (TypeScript.PullInstantiationHelpers.twoTypesAreInstantiationsOfSameNamedGenericType(expressionType, parameterType)) { + this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, argContext, context); + } else { + var symbolsWhenStartedWalkingTypes = context.startWalkingTypes(expressionType, parameterType); + this.relateObjectTypeToTypeParameters(expressionType, parameterType, argContext, context); + context.endWalkingTypes(symbolsWhenStartedWalkingTypes); } }; - PullTypeResolver.prototype.relateInifinitelyExpandingTypeToTypeParameters = function (expressionType, parameterType, shouldFix, argContext, context) { + PullTypeResolver.prototype.relateTypeArgumentsOfTypeToTypeParameters = function (expressionType, parameterType, argContext, context) { + var parameterSideTypeArguments = parameterType.getTypeArguments(); + var argumentSideTypeArguments = expressionType.getTypeArguments(); + + TypeScript.Debug.assert(parameterSideTypeArguments && argumentSideTypeArguments && parameterSideTypeArguments.length === argumentSideTypeArguments.length); + for (var i = 0; i < parameterSideTypeArguments.length; i++) { + this.relateTypeToTypeParametersWithNewEnclosingTypes(argumentSideTypeArguments[i], parameterSideTypeArguments[i], argContext, context); + } + }; + + PullTypeResolver.prototype.relateInifinitelyExpandingTypeToTypeParameters = function (expressionType, parameterType, argContext, context) { if (!expressionType || !parameterType) { return; } var expressionTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(expressionType); var parameterTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(parameterType); - if (expressionTypeNamedTypeReference != parameterTypeNamedTypeReference) { + if (expressionTypeNamedTypeReference !== parameterTypeNamedTypeReference) { return; } var expressionTypeTypeArguments = expressionType.getTypeArguments(); - var parameterTypeParameters = parameterType.getTypeParameters(); + var parameterTypeArguments = parameterType.getTypeArguments(); - if (expressionTypeTypeArguments && parameterTypeParameters && expressionTypeTypeArguments.length === parameterTypeParameters.length) { + if (expressionTypeTypeArguments && parameterTypeArguments && expressionTypeTypeArguments.length === parameterTypeArguments.length) { for (var i = 0; i < expressionTypeTypeArguments.length; i++) { - this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, context); + this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, argContext, context); } } }; PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, context) { - var expressionParams = expressionSignature.parameters; + var _this = this; var expressionReturnType = expressionSignature.returnType; - - var parameterParams = parameterSignature.parameters; var parameterReturnType = parameterSignature.returnType; - var len = parameterParams.length < expressionParams.length ? parameterParams.length : expressionParams.length; + parameterSignature.forAllCorrespondingParameterTypesInThisAndOtherSignature(expressionSignature, function (parameterSignatureParameterType, expressionSignatureParameterType, i) { + context.walkParameterTypes(i); + _this.relateTypeToTypeParametersInEnclosingType(expressionSignatureParameterType, parameterSignatureParameterType, argContext, context); + context.postWalkParameterTypes(); + return true; + }); - for (var i = 0; i < len; i++) { - this.relateTypeToTypeParametersInEnclosingType(expressionParams[i].type, parameterParams[i].type, expressionSignature.functionType, parameterSignature.functionType, true, argContext, context); - } - - this.relateTypeToTypeParametersInEnclosingType(expressionReturnType, parameterReturnType, expressionSignature.functionType, parameterSignature.functionType, false, argContext, context); + context.walkReturnTypes(); + this.relateTypeToTypeParametersInEnclosingType(expressionReturnType, parameterReturnType, argContext, context); + context.postWalkReturnTypes(); }; - PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, shouldFix, argContext, context) { + PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, argContext, context) { var parameterTypeMembers = parameterType.getMembers(); var parameterSignatures; @@ -47718,58 +49061,98 @@ var TypeScript; return; } - var objectTypeArguments = objectType.getTypeArguments(); - var parameterTypeParameters = parameterType.getTypeParameters(); - - if (objectTypeArguments) { - if (objectTypeArguments.length === parameterTypeParameters.length) { - for (var i = 0; i < objectTypeArguments.length; i++) { - argContext.addCandidateForInference(parameterTypeParameters[i], objectTypeArguments[i], shouldFix); - } - } else if (parameterType == this.semanticInfoChain.anyTypeSymbol) { - for (var i = 0; i < objectTypeArguments.length; i++) { - this.relateTypeToTypeParameters(parameterType, objectTypeArguments[i], shouldFix, argContext, context); - } - } - } - for (var i = 0; i < parameterTypeMembers.length; i++) { - objectMember = this.getMemberSymbol(parameterTypeMembers[i].name, 68147712 /* SomeValue */, objectType); + objectMember = this.getNamedPropertySymbol(parameterTypeMembers[i].name, 68147712 /* SomeValue */, objectType); if (objectMember) { - this.relateTypeToTypeParametersInEnclosingType(objectMember.type, parameterTypeMembers[i].type, objectType, parameterType, shouldFix, argContext, context); + this.resolveDeclaredSymbol(objectMember); + this.resolveDeclaredSymbol(parameterTypeMembers[i]); + context.walkMemberTypes(parameterTypeMembers[i].name); + this.relateTypeToTypeParametersInEnclosingType(objectMember.type, parameterTypeMembers[i].type, argContext, context); + context.postWalkMemberTypes(); } } - parameterSignatures = parameterType.getCallSignatures(); - objectSignatures = objectType.getCallSignatures(); + this.relateSignatureGroupToTypeParameters(objectType.getCallSignatures(), parameterType.getCallSignatures(), 1048576 /* CallSignature */, argContext, context); - if ((parameterSignatures.length == 1) && (objectSignatures.length == 1) && !objectSignatures[0].isGeneric() && (parameterSignatures[0].nonOptionalParamCount >= objectSignatures[0].nonOptionalParamCount)) { - this.relateFunctionSignatureToTypeParameters(objectSignatures[0], parameterSignatures[0], argContext, context); - } + this.relateSignatureGroupToTypeParameters(objectType.getConstructSignatures(), parameterType.getConstructSignatures(), 2097152 /* ConstructSignature */, argContext, context); - parameterSignatures = parameterType.getConstructSignatures(); - objectSignatures = objectType.getConstructSignatures(); - - if ((parameterSignatures.length == 1) && (objectSignatures.length == 1) && !objectSignatures[0].isGeneric() && (parameterSignatures[0].nonOptionalParamCount >= objectSignatures[0].nonOptionalParamCount)) { - this.relateFunctionSignatureToTypeParameters(objectSignatures[0], parameterSignatures[0], argContext, context); - } - - var parameterIndexSignatures = this.getBothKindsOfIndexSignatures(parameterType, context); - var objectIndexSignatures = this.getBothKindsOfIndexSignatures(objectType, context); + var parameterIndexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(parameterType, context); + var objectIndexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(objectType, context); + var indexSigInfo = context.getBothKindOfIndexSignatures(false, false); if (parameterIndexSignatures.stringSignature && objectIndexSignatures.stringSignature) { + context.walkIndexSignatureReturnTypes(indexSigInfo, true, true, true); this.relateFunctionSignatureToTypeParameters(objectIndexSignatures.stringSignature, parameterIndexSignatures.stringSignature, argContext, context); + context.postWalkIndexSignatureReturnTypes(true); } if (parameterIndexSignatures.numericSignature && objectIndexSignatures.numericSignature) { + context.walkIndexSignatureReturnTypes(indexSigInfo, false, false, true); this.relateFunctionSignatureToTypeParameters(objectIndexSignatures.numericSignature, parameterIndexSignatures.numericSignature, argContext, context); + context.postWalkIndexSignatureReturnTypes(true); } }; - PullTypeResolver.prototype.relateArrayTypeToTypeParameters = function (argArrayType, parameterArrayType, shouldFix, argContext, context) { - var argElement = argArrayType.getElementType(); - var paramElement = parameterArrayType.getElementType(); + PullTypeResolver.prototype.relateSignatureGroupToTypeParameters = function (argumentSignatures, parameterSignatures, signatureKind, argContext, context) { + for (var i = 0; i < parameterSignatures.length; i++) { + var paramSignature = parameterSignatures[i]; + if (argumentSignatures.length > 0 && paramSignature.isGeneric()) { + paramSignature = this.instantiateSignatureToAny(paramSignature); + } + for (var j = 0; j < argumentSignatures.length; j++) { + var argumentSignature = argumentSignatures[j]; + if (argumentSignature.nonOptionalParamCount > paramSignature.nonOptionalParamCount) { + continue; + } - this.relateTypeToTypeParameters(argElement, paramElement, shouldFix, argContext, context); + if (argumentSignature.isGeneric()) { + argumentSignature = this.instantiateSignatureToAny(argumentSignature); + } + + context.walkSignatures(signatureKind, j, i); + this.relateFunctionSignatureToTypeParameters(argumentSignature, paramSignature, argContext, context); + context.postWalkSignatures(); + } + } + }; + + PullTypeResolver.prototype.alterPotentialGenericFunctionTypeToInstantiatedFunctionTypeForTypeArgumentInference = function (expressionSymbol, context) { + var inferentialType = context.getContextualType(); + TypeScript.Debug.assert(inferentialType); + var expressionType = expressionSymbol.type; + if (this.isFunctionTypeWithExactlyOneCallSignatureAndNoOtherMembers(expressionType, true) && this.isFunctionTypeWithExactlyOneCallSignatureAndNoOtherMembers(inferentialType, false)) { + var genericExpressionSignature = expressionType.getCallSignatures()[0]; + var contextualSignature = inferentialType.getCallSignatures()[0]; + + var instantiatedSignature = this.instantiateSignatureInContext(genericExpressionSignature, contextualSignature, context, true); + if (instantiatedSignature === null) { + return expressionSymbol; + } + + var newType = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + newType.appendCallSignature(instantiatedSignature); + return newType; + } + + return expressionSymbol; + }; + + PullTypeResolver.prototype.isFunctionTypeWithExactlyOneCallSignatureAndNoOtherMembers = function (type, callSignatureShouldBeGeneric) { + TypeScript.Debug.assert(type); + if (type.getCallSignatures().length !== 1) { + return false; + } + + var callSignatureIsGeneric = type.getCallSignatures()[0].isGeneric(); + if (callSignatureIsGeneric !== callSignatureShouldBeGeneric) { + return false; + } + + var typeHasOtherMembers = type.getConstructSignatures().length || type.getIndexSignatures().length || type.getAllMembers(68147712 /* SomeValue */, 0 /* all */).length; + if (typeHasOtherMembers) { + return false; + } + + return true; }; PullTypeResolver.prototype.instantiateTypeToAny = function (typeToSpecialize, context) { @@ -47806,6 +49189,32 @@ var TypeScript; return type; }; + PullTypeResolver.prototype.instantiateSignatureToAny = function (signature) { + var typeParameters = signature.getTypeParameters(); + if (!this._cachedAnyTypeArgs) { + this._cachedAnyTypeArgs = [ + [this.semanticInfoChain.anyTypeSymbol], + [this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol], + [this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol], + [this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol], + [this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol, this.semanticInfoChain.anyTypeSymbol] + ]; + } + + if (typeParameters.length < this._cachedAnyTypeArgs.length) { + var typeArguments = this._cachedAnyTypeArgs[typeParameters.length - 1]; + } else { + var typeArguments = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeArguments[typeArguments.length] = this.semanticInfoChain.anyTypeSymbol; + } + } + + var typeParameterArgumentMap = TypeScript.PullInstantiationHelpers.createTypeParameterArgumentMap(typeParameters, typeArguments); + return this.instantiateSignature(signature, typeParameterArgumentMap); + }; + PullTypeResolver.typeCheck = function (compilationSettings, semanticInfoChain, document) { var sourceUnit = document.sourceUnit(); @@ -47826,66 +49235,23 @@ var TypeScript; }; PullTypeResolver.prototype.validateVariableDeclarationGroups = function (enclosingDecl, context) { - var importDeclarationNames = null; - if (enclosingDecl.kind & (4 /* Container */ | 32 /* DynamicModule */ | 1 /* Script */)) { - var childDecls = enclosingDecl.getChildDecls(); - for (var i = 0, n = childDecls.length; i < n; i++) { - var childDecl = childDecls[i]; - if (childDecl.kind === 128 /* TypeAlias */) { - importDeclarationNames = importDeclarationNames || TypeScript.createIntrinsicsObject(); - importDeclarationNames[childDecl.name] = true; - } - } - } - - var declGroups = enclosingDecl.getVariableDeclGroups(); - - for (var i = 0, i_max = declGroups.length; i < i_max; i++) { - var firstSymbol = null; - var firstSymbolType = null; - - if (enclosingDecl.kind === 1 /* Script */ && declGroups[i].length) { - var name = declGroups[i][0].name; - var candidateSymbol = this.semanticInfoChain.findTopLevelSymbol(name, 512 /* Variable */, enclosingDecl); - if (candidateSymbol && candidateSymbol.isResolved) { - if (!candidateSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */)) { - firstSymbol = candidateSymbol; - firstSymbolType = candidateSymbol.type; - } - } - - var importSymbol = this.semanticInfoChain.findTopLevelSymbol(name, 128 /* TypeAlias */, null); - if (importSymbol && importSymbol.isAlias()) { - importDeclarationNames = importDeclarationNames || TypeScript.createIntrinsicsObject(); - } + var _this = this; + this.scanVariableDeclarationGroups(enclosingDecl, function (_) { + }, function (subsequentDecl, firstSymbol) { + if (TypeScript.hasFlag(subsequentDecl.kind, 2048 /* Parameter */) || TypeScript.hasFlag(subsequentDecl.flags, 8388608 /* PropertyParameter */)) { + return; } - for (var j = 0, j_max = declGroups[i].length; j < j_max; j++) { - var decl = declGroups[i][j]; - var boundDeclAST = this.semanticInfoChain.getASTForDecl(decl); + var boundDeclAST = _this.semanticInfoChain.getASTForDecl(subsequentDecl); - var name = decl.name; + var symbol = subsequentDecl.getSymbol(); + var symbolType = symbol.type; + var firstSymbolType = firstSymbol.type; - if (importDeclarationNames && importDeclarationNames[name]) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(boundDeclAST, TypeScript.DiagnosticCode.Variable_declaration_cannot_have_the_same_name_as_an_import_declaration)); - continue; - } - - var symbol = decl.getSymbol(); - var symbolType = symbol.type; - - if (j === 0 && !firstSymbol) { - firstSymbol = symbol; - firstSymbolType = symbolType; - continue; - } - - if (symbolType && firstSymbolType && symbolType !== firstSymbolType && !this.typesAreIdentical(symbolType, firstSymbolType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(boundDeclAST, TypeScript.DiagnosticCode.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, [symbol.getScopedName(), firstSymbolType.toString(), symbolType.toString()])); - continue; - } + if (symbolType && firstSymbolType && symbolType !== firstSymbolType && !_this.typesAreIdentical(symbolType, firstSymbolType, context)) { + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(boundDeclAST, TypeScript.DiagnosticCode.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, [symbol.getScopedName(), firstSymbolType.toString(firstSymbol), symbolType.toString(symbol)])); } - } + }); }; PullTypeResolver.prototype.typeCheckFunctionOverloads = function (funcDecl, context, signature, allSignatures) { @@ -47906,13 +49272,19 @@ var TypeScript; } if (!signature.isDefinition()) { + var signatureParentDecl = signature.getDeclarations()[0].getParentDecl(); for (var i = 0; i < allSignatures.length; i++) { if (allSignatures[i] === signature) { break; } - if (this.signaturesAreIdentical(allSignatures[i], signature, false)) { - if (!this.typesAreIdentical(allSignatures[i].returnType, signature.returnType)) { + var allSignaturesParentDecl = allSignatures[i].getDeclarations()[0].getParentDecl(); + if (allSignaturesParentDecl !== signatureParentDecl) { + continue; + } + + if (this.signaturesAreIdenticalWithNewEnclosingTypes(allSignatures[i], signature, context, false)) { + if (!this.signatureReturnTypesAreIdentical(allSignatures[i], signature, context)) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overloads_cannot_differ_only_by_return_type)); } else if (funcDecl.kind() === 137 /* ConstructorDeclaration */) { context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_constructor_overload_signature)); @@ -47948,17 +49320,17 @@ var TypeScript; continue; } - if (this.signatureIsSubtypeOfTarget(signature, allSignatures[i], null, context)) { + if (this.signatureIsAssignableToTarget(signature, allSignatures[i], null, context)) { foundSubtypeSignature = true; break; } } if (!foundSubtypeSignature) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Specialized_overload_signature_is_not_subtype_of_any_non_specialized_signature)); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature)); } } - } else if (definitionSignature && definitionSignature != signature) { + } else if (definitionSignature && definitionSignature !== signature) { var comparisonInfo = new TypeComparisonInfo(); if (!definitionSignature.isResolved) { @@ -47982,16 +49354,16 @@ var TypeScript; signatureForVisibilityCheck = allSignatures[0]; } - if (funcDecl.kind() !== 137 /* ConstructorDeclaration */ && functionDeclaration.kind !== 2097152 /* ConstructSignature */ && signatureForVisibilityCheck && signature != signatureForVisibilityCheck) { + if (funcDecl.kind() !== 137 /* ConstructorDeclaration */ && functionDeclaration.kind !== 2097152 /* ConstructSignature */ && signatureForVisibilityCheck && signature !== signatureForVisibilityCheck) { var errorCode; - if (signatureForVisibilityCheck.anyDeclHasFlag(2 /* Private */) != signature.anyDeclHasFlag(2 /* Private */)) { + if (signatureForVisibilityCheck.anyDeclHasFlag(2 /* Private */) !== signature.anyDeclHasFlag(2 /* Private */)) { errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_public_or_private; - } else if (signatureForVisibilityCheck.anyDeclHasFlag(1 /* Exported */) != signature.anyDeclHasFlag(1 /* Exported */)) { + } else if (signatureForVisibilityCheck.anyDeclHasFlag(1 /* Exported */) !== signature.anyDeclHasFlag(1 /* Exported */)) { errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_exported_or_not_exported; - } else if (signatureForVisibilityCheck.anyDeclHasFlag(8 /* Ambient */) != signature.anyDeclHasFlag(8 /* Ambient */)) { + } else if (signatureForVisibilityCheck.anyDeclHasFlag(8 /* Ambient */) !== signature.anyDeclHasFlag(8 /* Ambient */)) { errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_ambient_or_non_ambient; - } else if (signatureForVisibilityCheck.anyDeclHasFlag(128 /* Optional */) != signature.anyDeclHasFlag(128 /* Optional */)) { + } else if (signatureForVisibilityCheck.anyDeclHasFlag(128 /* Optional */) !== signature.anyDeclHasFlag(128 /* Optional */)) { errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_optional_or_required; } @@ -48045,7 +49417,7 @@ var TypeScript; this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), privacyErrorReporter); this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), privacyErrorReporter); this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), privacyErrorReporter); - } else if (typeSymbol.kind == 8192 /* TypeParameter */) { + } else if (typeSymbol.kind === 8192 /* TypeParameter */) { this.checkSymbolPrivacy(declSymbol, typeSymbol.getConstraint(), privacyErrorReporter); } @@ -48059,27 +49431,27 @@ var TypeScript; if (declSymbol.isExternallyVisible()) { var symbolIsVisible = symbol.isExternallyVisible(); - if (symbolIsVisible && symbol.kind != 8192 /* TypeParameter */) { + if (symbolIsVisible && symbol.kind !== 8192 /* TypeParameter */) { var symbolPath = symbol.pathToRoot(); var declSymbolPath = declSymbol.pathToRoot(); - if (symbolPath[symbolPath.length - 1].kind === 32 /* DynamicModule */ && declSymbolPath[declSymbolPath.length - 1].kind == 32 /* DynamicModule */ && declSymbolPath[declSymbolPath.length - 1] != symbolPath[symbolPath.length - 1]) { + if (symbolPath[symbolPath.length - 1].kind === 32 /* DynamicModule */ && declSymbolPath[declSymbolPath.length - 1].kind === 32 /* DynamicModule */ && declSymbolPath[declSymbolPath.length - 1] !== symbolPath[symbolPath.length - 1]) { symbolIsVisible = false; var declSymbolScope = declSymbolPath[declSymbolPath.length - 1]; for (var i = symbolPath.length - 1; i >= 0; i--) { var aliasSymbols = symbolPath[i].getExternalAliasedSymbols(declSymbolScope); if (aliasSymbols) { symbolIsVisible = true; - aliasSymbols[0].setTypeUsedExternally(true); + aliasSymbols[0].setTypeUsedExternally(); break; } } symbol = symbolPath[symbolPath.length - 1]; } - } else if (symbol.kind == 128 /* TypeAlias */) { + } else if (symbol.kind === 128 /* TypeAlias */) { var aliasSymbol = symbol; symbolIsVisible = true; - aliasSymbol.setTypeUsedExternally(true); + aliasSymbol.setTypeUsedExternally(); } if (!symbolIsVisible) { @@ -48111,7 +49483,7 @@ var TypeScript; } }; - PullTypeResolver.prototype.typeParameterOfTypeDeclarationPrivacyErrorReporter = function (classOrInterface, indexOfTypeParameter, typeParameter, symbol, context) { + PullTypeResolver.prototype.typeParameterOfTypeDeclarationPrivacyErrorReporter = function (classOrInterface, typeParameterAST, typeParameter, symbol, context) { var decl = this.semanticInfoChain.getDeclForAST(classOrInterface); var enclosingDecl = this.getEnclosingDecl(decl); var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; @@ -48119,8 +49491,6 @@ var TypeScript; var typeParameters = classOrInterface.kind() === 131 /* ClassDeclaration */ ? classOrInterface.typeParameterList : classOrInterface.typeParameterList; - var typeParameterAST = typeParameters.typeParameters.nonSeparatorAt(indexOfTypeParameter); - var typeSymbol = symbol; var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { @@ -48254,7 +49624,7 @@ var TypeScript; if (functionSymbol && functionSymbol.isType() && !functionSymbol.isNamedTypeSymbol()) { return; } - } else if (functionSymbol.kind == 65536 /* Method */ && !isStatic && !functionSymbol.getContainer().isNamedTypeSymbol()) { + } else if (functionSymbol.kind === 65536 /* Method */ && !isStatic && !functionSymbol.getContainer().isNamedTypeSymbol()) { return; } functionSignature = functionDecl.getSignatureSymbol(); @@ -48659,7 +50029,7 @@ var TypeScript; }; PullTypeResolver.prototype.typeCheckMembersAgainstIndexer = function (containerType, containerTypeDecl, context) { - var indexSignatures = this.getBothKindsOfIndexSignatures(containerType, context); + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(containerType, context); var stringSignature = indexSignatures.stringSignature; var numberSignature = indexSignatures.numericSignature; @@ -48672,7 +50042,7 @@ var TypeScript; var relevantSignature = this.determineRelevantIndexerForMember(memberSymbol, numberSignature, stringSignature); if (relevantSignature) { var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsSubtypeOfTarget(memberSymbol.type, relevantSignature.returnType, member.ast(), context, comparisonInfo)) { + if (!this.sourceIsAssignableToTarget(memberSymbol.type, relevantSignature.returnType, member.ast(), context, comparisonInfo)) { this.reportErrorThatMemberIsNotSubtypeOfIndexer(memberSymbol, relevantSignature, member.ast(), context, comparisonInfo); } } @@ -48695,15 +50065,15 @@ var TypeScript; var enclosingSymbol = this.getEnclosingSymbolForAST(astForError); if (indexSignature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol) { if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type_0_NL_1, [indexSignature.returnType.toString(enclosingSymbol), comparisonInfo.message])); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_numerically_named_properties_must_be_assignable_to_numeric_indexer_type_0_NL_1, [indexSignature.returnType.toString(enclosingSymbol), comparisonInfo.message])); } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_numerically_named_properties_must_be_subtypes_of_numeric_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_numerically_named_properties_must_be_assignable_to_numeric_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); } } else { if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_named_properties_must_be_subtypes_of_string_indexer_type_0_NL_1, [indexSignature.returnType.toString(enclosingSymbol), comparisonInfo.message])); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_named_properties_must_be_assignable_to_string_indexer_type_0_NL_1, [indexSignature.returnType.toString(enclosingSymbol), comparisonInfo.message])); } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_named_properties_must_be_subtypes_of_string_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_named_properties_must_be_assignable_to_string_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); } } }; @@ -48756,7 +50126,7 @@ var TypeScript; foundError1 = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, enclosingDecl, comparisonInfo); if (!foundError1) { - foundError2 = !this.sourcePropertyIsSubtypeOfTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, classOrInterface, context, comparisonInfo); + foundError2 = !this.sourcePropertyIsAssignableToTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, classOrInterface, context, comparisonInfo); } if (foundError1 || foundError2) { @@ -48767,15 +50137,15 @@ var TypeScript; } if (!foundError && typeSymbol.hasOwnCallSignatures()) { - foundError = !this.sourceCallSignaturesAreSubtypeOfTargetCallSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); } if (!foundError && typeSymbol.hasOwnConstructSignatures()) { - foundError = !this.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); } if (!foundError && typeSymbol.hasOwnIndexSignatures()) { - foundError = !this.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); } if (!foundError && typeSymbol.isClass()) { @@ -48793,17 +50163,7 @@ var TypeScript; this.resolveDeclaredSymbol(extendedConstructorTypeProp, context); } - var typeConstructorTypePropType = typeConstructorTypeMembers[i].type; - var extendedConstructorTypePropType = extendedConstructorTypeProp.type; - if (!this.sourceIsSubtypeOfTarget(typeConstructorTypePropType, extendedConstructorTypePropType, classOrInterface, context, comparisonInfoForPropTypeCheck)) { - var propMessage; - var enclosingSymbol = this.getEnclosingSymbolForAST(classOrInterface); - if (comparisonInfoForPropTypeCheck.message) { - propMessage = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_static_property_0_of_class_1_and_class_2_are_incompatible_NL_3, [extendedConstructorTypeProp.getScopedNameEx().toString(), typeSymbol.toString(enclosingSymbol), extendedType.toString(enclosingSymbol), comparisonInfoForPropTypeCheck.message]); - } else { - propMessage = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_static_property_0_of_class_1_and_class_2_are_incompatible, [extendedConstructorTypeProp.getScopedNameEx().toString(), typeSymbol.toString(enclosingSymbol), extendedType.toString(enclosingSymbol)]); - } - comparisonInfo.addMessage(propMessage); + if (!this.sourcePropertyIsAssignableToTargetProperty(typeConstructorType, extendedConstructorType, typeConstructorTypeMembers[i], extendedConstructorTypeProp, classOrInterface, context, comparisonInfo)) { foundError = true; break; } @@ -48830,13 +50190,13 @@ var TypeScript; PullTypeResolver.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, enclosingDecl, context) { var comparisonInfo = new TypeComparisonInfo(); - var foundError = !this.sourceMembersAreSubtypeOfTargetMembers(classSymbol, implementedType, classDecl, context, comparisonInfo); + var foundError = !this.sourceMembersAreAssignableToTargetMembers(classSymbol, implementedType, classDecl, context, comparisonInfo); if (!foundError) { - foundError = !this.sourceCallSignaturesAreSubtypeOfTargetCallSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); if (!foundError) { - foundError = !this.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); if (!foundError) { - foundError = !this.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); } } } @@ -48847,15 +50207,39 @@ var TypeScript; } }; - PullTypeResolver.prototype.hasClassTypeSymbolConflictAsValue = function (valueDeclAST, typeSymbol, enclosingDecl, context) { + PullTypeResolver.prototype.computeValueSymbolFromAST = function (valueDeclAST, context) { + var prevInTypeCheck = context.inTypeCheck; + context.inTypeCheck = false; + var typeSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); - var valueSymbol = this.computeNameExpression(valueDeclAST, context, false); + + if (valueDeclAST.kind() == 11 /* IdentifierName */) { + var valueSymbol = this.computeNameExpression(valueDeclAST, context); + } else { + TypeScript.Debug.assert(valueDeclAST.kind() == 121 /* QualifiedName */); + var qualifiedName = valueDeclAST; + + var lhs = this.computeValueSymbolFromAST(qualifiedName.left, context); + var valueSymbol = this.computeDottedNameExpressionFromLHS(lhs.symbol, qualifiedName.left, qualifiedName.right, context, false); + } var valueSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); this.semanticInfoChain.setAliasSymbolForAST(valueDeclAST, typeSymbolAlias); + context.inTypeCheck = prevInTypeCheck; + + return { symbol: valueSymbol, alias: valueSymbolAlias }; + }; + + PullTypeResolver.prototype.hasClassTypeSymbolConflictAsValue = function (baseDeclAST, typeSymbol, enclosingDecl, context) { + var typeSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(baseDeclAST); + + var valueDeclAST = baseDeclAST.kind() == 126 /* GenericType */ ? baseDeclAST.name : baseDeclAST; + var valueSymbolInfo = this.computeValueSymbolFromAST(valueDeclAST, context); + var valueSymbol = valueSymbolInfo.symbol; + var valueSymbolAlias = valueSymbolInfo.alias; if (typeSymbolAlias && valueSymbolAlias) { - return typeSymbolAlias != valueSymbolAlias; + return typeSymbolAlias !== valueSymbolAlias; } if (!valueSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */)) { @@ -48865,7 +50249,7 @@ var TypeScript; var associatedContainerType = valueSymbol.type ? valueSymbol.type.getAssociatedContainerType() : null; if (associatedContainerType) { - return associatedContainerType != typeSymbol.getRootSymbol(); + return associatedContainerType !== typeSymbol.getRootSymbol(); } return true; @@ -48896,9 +50280,9 @@ var TypeScript; } } return; - } else if (typeDeclIsClass && isExtendedType && baseDeclAST.kind() == 11 /* IdentifierName */) { + } else if (typeDeclIsClass && isExtendedType) { if (this.hasClassTypeSymbolConflictAsValue(baseDeclAST, baseType, enclosingDecl, context)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.Type_reference_0_in_extends_clause_does_not_reference_constructor_function_for_1, [baseDeclAST.text(), baseType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_1, [TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(baseDeclAST.kind() == 126 /* GenericType */ ? baseDeclAST.name : baseDeclAST), baseType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); } } @@ -48911,11 +50295,15 @@ var TypeScript; } if (isExtendedType) { - this.typeCheckIfTypeExtendsType(classOrInterface, name, typeSymbol, baseType, enclosingDecl, context); + this.typeCheckCallBacks.push(function (context) { + return _this.typeCheckIfTypeExtendsType(classOrInterface, name, typeSymbol, baseType, enclosingDecl, context); + }); } else { TypeScript.Debug.assert(classOrInterface.kind() === 131 /* ClassDeclaration */); - this.typeCheckIfClassImplementsType(classOrInterface, typeSymbol, baseType, enclosingDecl, context); + this.typeCheckCallBacks.push(function (context) { + return _this.typeCheckIfClassImplementsType(classOrInterface, typeSymbol, baseType, enclosingDecl, context); + }); } this.checkSymbolPrivacy(typeSymbol, baseType, function (errorSymbol) { @@ -48925,14 +50313,12 @@ var TypeScript; PullTypeResolver.prototype.typeCheckBases = function (classOrInterface, name, heritageClauses, typeSymbol, enclosingDecl, context) { var _this = this; - var extendsClause = TypeScript.getExtendsHeritageClause(heritageClauses); - var implementsClause = TypeScript.getImplementsHeritageClause(heritageClauses); + var extendsClause = TypeScript.ASTHelpers.getExtendsHeritageClause(heritageClauses); + var implementsClause = TypeScript.ASTHelpers.getImplementsHeritageClause(heritageClauses); if (!extendsClause && !implementsClause) { return; } - var typeDeclIsClass = classOrInterface.kind() === 131 /* ClassDeclaration */; - if (extendsClause) { for (var i = 0; i < extendsClause.typeNames.nonSeparatorCount(); i++) { this.typeCheckBase(classOrInterface, name, typeSymbol, extendsClause.typeNames.nonSeparatorAt(i), true, enclosingDecl, context); @@ -48978,7 +50364,7 @@ var TypeScript; } var baseTypes = typeSymbol.getExtendedTypes(); for (var i = 0; i < baseTypes.length; i++) { - if (this.checkNamedPropertyTypeIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedMembersMap, context) || this.checkIndexSignatureIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedIndexSignatures, typeHasOwnNumberIndexer, typeHasOwnStringIndexer, context)) { + if (this.checkNamedPropertyIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedMembersMap, context) || this.checkIndexSignatureIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedIndexSignatures, typeHasOwnNumberIndexer, typeHasOwnStringIndexer, context)) { return; } } @@ -48990,7 +50376,7 @@ var TypeScript; this.checkInheritedMembersAgainstInheritedIndexSignatures(name, typeSymbol, inheritedIndexSignatures, inheritedMembersMap, context); }; - PullTypeResolver.prototype.checkNamedPropertyTypeIdentityBetweenBases = function (interfaceName, interfaceSymbol, baseTypeSymbol, inheritedMembersMap, context) { + PullTypeResolver.prototype.checkNamedPropertyIdentityBetweenBases = function (interfaceName, interfaceSymbol, baseTypeSymbol, inheritedMembersMap, context) { var baseMembers = baseTypeSymbol.getAllMembers(4096 /* Property */ | 65536 /* Method */, 0 /* all */); for (var i = 0; i < baseMembers.length; i++) { var member = baseMembers[i]; @@ -49000,10 +50386,12 @@ var TypeScript; continue; } + this.resolveDeclaredSymbol(member, context); + if (inheritedMembersMap[memberName]) { var prevMember = inheritedMembersMap[memberName]; - if (prevMember.baseOrigin !== baseTypeSymbol && !this.typesAreIdentical(member.type, prevMember.memberSymbol.type)) { - var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_property_0_of_types_1_and_2_are_not_identical, [memberName, prevMember.baseOrigin.getScopedName(), baseTypeSymbol.getScopedName()]); + if (prevMember.baseOrigin !== baseTypeSymbol && !this.propertiesAreIdenticalWithNewEnclosingTypes(baseTypeSymbol, prevMember.baseOrigin, member, prevMember.memberSymbol, context)) { + var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Named_properties_0_of_types_1_and_2_are_not_identical, [memberName, prevMember.baseOrigin.getScopedName(), baseTypeSymbol.getScopedName()]); context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(interfaceName, TypeScript.DiagnosticCode.Interface_0_cannot_simultaneously_extend_types_1_and_2_NL_3, [interfaceSymbol.getDisplayName(), prevMember.baseOrigin.getScopedName(), baseTypeSymbol.getScopedName(), innerDiagnostic])); return true; } @@ -49025,14 +50413,15 @@ var TypeScript; var currentInheritedSignature = indexSignaturesFromThisBaseType[i]; var parameterTypeIsString = currentInheritedSignature.parameters[0].type === this.semanticInfoChain.stringTypeSymbol; - var parameterTypeIsNumber = !parameterTypeIsString; + var parameterTypeIsNumber = currentInheritedSignature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol; + if (parameterTypeIsString && derivedTypeHasOwnStringSignature || parameterTypeIsNumber && derivedTypeHasOwnNumberSignature) { continue; } if (parameterTypeIsString) { if (allInheritedSignatures.stringSignatureWithBaseOrigin) { - if (allInheritedSignatures.stringSignatureWithBaseOrigin.baseOrigin !== baseTypeSymbol && !this.typesAreIdentical(allInheritedSignatures.stringSignatureWithBaseOrigin.signature.returnType, currentInheritedSignature.returnType)) { + if (allInheritedSignatures.stringSignatureWithBaseOrigin.baseOrigin !== baseTypeSymbol && !this.typesAreIdentical(allInheritedSignatures.stringSignatureWithBaseOrigin.signature.returnType, currentInheritedSignature.returnType, context)) { var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_string_indexer_of_types_0_and_1_are_not_identical, [allInheritedSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(), baseTypeSymbol.getScopedName()]); context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(interfaceName, TypeScript.DiagnosticCode.Interface_0_cannot_simultaneously_extend_types_1_and_2_NL_3, [interfaceSymbol.getDisplayName(), allInheritedSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(), baseTypeSymbol.getScopedName(), innerDiagnostic])); return true; @@ -49042,7 +50431,7 @@ var TypeScript; } } else if (parameterTypeIsNumber) { if (allInheritedSignatures.numberSignatureWithBaseOrigin) { - if (allInheritedSignatures.numberSignatureWithBaseOrigin.baseOrigin !== baseTypeSymbol && !this.typesAreIdentical(allInheritedSignatures.numberSignatureWithBaseOrigin.signature.returnType, currentInheritedSignature.returnType)) { + if (allInheritedSignatures.numberSignatureWithBaseOrigin.baseOrigin !== baseTypeSymbol && !this.typesAreIdentical(allInheritedSignatures.numberSignatureWithBaseOrigin.signature.returnType, currentInheritedSignature.returnType, context)) { var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Types_of_number_indexer_of_types_0_and_1_are_not_identical, [allInheritedSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(), baseTypeSymbol.getScopedName()]); context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(interfaceName, TypeScript.DiagnosticCode.Interface_0_cannot_simultaneously_extend_types_1_and_2_NL_3, [interfaceSymbol.getDisplayName(), allInheritedSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(), baseTypeSymbol.getScopedName(), innerDiagnostic])); return true; @@ -49082,16 +50471,16 @@ var TypeScript; continue; } - var memberIsSubtype = this.sourceIsSubtypeOfTarget(memberWithBaseOrigin.memberSymbol.type, relevantSignature.returnType, interfaceName, context, comparisonInfo); + var memberIsSubtype = this.sourceIsAssignableToTarget(memberWithBaseOrigin.memberSymbol.type, relevantSignature.returnType, interfaceName, context, comparisonInfo); if (!memberIsSubtype) { var enclosingSymbol = this.getEnclosingSymbolForAST(interfaceName); if (relevantSignatureIsNumberSignature) { - var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_of_property_0_in_type_1_is_not_a_subtype_of_number_indexer_type_in_type_2_NL_3, [memberName, memberWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), comparisonInfo.message]); + var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_of_property_0_in_type_1_is_not_assignable_to_number_indexer_type_in_type_2_NL_3, [memberName, memberWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), comparisonInfo.message]); context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(interfaceName, TypeScript.DiagnosticCode.Interface_0_cannot_simultaneously_extend_types_1_and_2_NL_3, [interfaceSymbol.getDisplayName(enclosingSymbol), memberWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), innerDiagnostic])); } else { - var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_of_property_0_in_type_1_is_not_a_subtype_of_string_indexer_type_in_type_2_NL_3, [memberName, memberWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), comparisonInfo.message]); + var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_of_property_0_in_type_1_is_not_assignable_to_string_indexer_type_in_type_2_NL_3, [memberName, memberWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), comparisonInfo.message]); context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(interfaceName, TypeScript.DiagnosticCode.Interface_0_cannot_simultaneously_extend_types_1_and_2_NL_3, [interfaceSymbol.getDisplayName(enclosingSymbol), memberWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), innerDiagnostic])); } @@ -49109,11 +50498,11 @@ var TypeScript; } var comparisonInfo = new TypeComparisonInfo(); - var signatureIsSubtype = this.sourceIsSubtypeOfTarget(inheritedIndexSignatures.numberSignatureWithBaseOrigin.signature.returnType, inheritedIndexSignatures.stringSignatureWithBaseOrigin.signature.returnType, interfaceName, context, comparisonInfo); + var signatureIsSubtype = this.sourceIsAssignableToTarget(inheritedIndexSignatures.numberSignatureWithBaseOrigin.signature.returnType, inheritedIndexSignatures.stringSignatureWithBaseOrigin.signature.returnType, interfaceName, context, comparisonInfo); if (!signatureIsSubtype) { var enclosingSymbol = this.getEnclosingSymbolForAST(interfaceName); - var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_of_number_indexer_in_type_0_is_not_a_subtype_of_string_indexer_type_in_type_1_NL_2, [ + var innerDiagnostic = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_of_number_indexer_in_type_0_is_not_assignable_to_string_indexer_type_in_type_1_NL_2, [ inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), comparisonInfo.message]); context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(interfaceName, TypeScript.DiagnosticCode.Interface_0_cannot_simultaneously_extend_types_1_and_2_NL_3, [ @@ -49159,7 +50548,7 @@ var TypeScript; return false; } - if (astSymbol.kind === 32768 /* ConstructorMethod */) { + if (astSymbol.kind === 32768 /* ConstructorMethod */ || astSymbol.kind === 16384 /* Function */) { return false; } } @@ -49216,8 +50605,7 @@ var TypeScript; return false; }; - PullTypeResolver.prototype.instantiateType = function (type, typeParameterArgumentMap, instantiateFunctionTypeParameters) { - if (typeof instantiateFunctionTypeParameters === "undefined") { instantiateFunctionTypeParameters = false; } + PullTypeResolver.prototype.instantiateType = function (type, typeParameterArgumentMap) { if (type.isPrimitive()) { return type; } @@ -49230,48 +50618,63 @@ var TypeScript; return typeParameterArgumentMap[type.pullSymbolID]; } - if (type.isTypeParameter() && type.isFunctionTypeParameter()) { - return type; + type._resolveDeclaredSymbol(); + if (type.isTypeParameter()) { + return this.instantiateTypeParameter(type, typeParameterArgumentMap); } - type._resolveDeclaredSymbol(); if (type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap, instantiateFunctionTypeParameters); + return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); } return type; }; - PullTypeResolver.prototype.instantiateSignature = function (signature, typeParameterArgumentMap, instantiateFunctionTypeParameters) { - if (typeof instantiateFunctionTypeParameters === "undefined") { instantiateFunctionTypeParameters = false; } + PullTypeResolver.prototype.instantiateTypeParameter = function (typeParameter, typeParameterArgumentMap) { + var constraint = typeParameter.getConstraint(); + if (!constraint) { + return typeParameter; + } + + var instantiatedConstraint = this.instantiateType(constraint, typeParameterArgumentMap); + + if (instantiatedConstraint == constraint) { + return typeParameter; + } + + var rootTypeParameter = typeParameter.getRootSymbol(); + var instantiation = rootTypeParameter.getSpecialization([instantiatedConstraint]); + if (instantiation) { + return instantiation; + } + + instantiation = new TypeScript.PullInstantiatedTypeParameterSymbol(rootTypeParameter, instantiatedConstraint); + return instantiation; + }; + + PullTypeResolver.prototype.instantiateSignature = function (signature, typeParameterArgumentMap) { if (!signature.wrapsSomeTypeParameter(typeParameterArgumentMap)) { return signature; } - var typeArguments = []; + var rootSignature = signature.getRootSymbol(); + var mutableTypeParameterMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(typeParameterArgumentMap); + TypeScript.PullInstantiationHelpers.instantiateTypeArgument(this, signature, mutableTypeParameterMap); - TypeScript.nSpecializedSignaturesCreated++; - - var instantiatedSignature = new TypeScript.PullSignatureSymbol(signature.kind); - instantiatedSignature.setRootSymbol(signature); - - var typeParameters = signature.getTypeParameters(); - var constraint = null; - var typeParameter = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = typeParameters[i]; - - instantiatedSignature.addTypeParameter(typeParameter); + var instantiatedSignature = rootSignature.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); + if (instantiatedSignature) { + return instantiatedSignature; } - instantiatedSignature.returnType = this.instantiateType((signature.returnType || this.semanticInfoChain.anyTypeSymbol), typeParameterArgumentMap, instantiateFunctionTypeParameters); + TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(signature, mutableTypeParameterMap); + typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; - if (instantiateFunctionTypeParameters) { - instantiatedSignature.functionType = this.instantiateType(signature.functionType, typeParameterArgumentMap, instantiateFunctionTypeParameters); - } + instantiatedSignature = new TypeScript.PullInstantiatedSignatureSymbol(rootSignature, typeParameterArgumentMap); - var parameters = signature.parameters; + instantiatedSignature.returnType = this.instantiateType((rootSignature.returnType || this.semanticInfoChain.anyTypeSymbol), typeParameterArgumentMap); + instantiatedSignature.functionType = this.instantiateType(rootSignature.functionType, typeParameterArgumentMap); + + var parameters = rootSignature.parameters; var parameter = null; if (parameters) { @@ -49288,7 +50691,7 @@ var TypeScript; } instantiatedSignature.addParameter(parameter, parameter.isOptional); - parameter.type = this.instantiateType(parameters[j].type, typeParameterArgumentMap, instantiateFunctionTypeParameters); + parameter.type = this.instantiateType(parameters[j].type, typeParameterArgumentMap); } } @@ -49300,7 +50703,7 @@ var TypeScript; TypeScript.PullTypeResolver = PullTypeResolver; var TypeComparisonInfo = (function () { - function TypeComparisonInfo(sourceComparisonInfo) { + function TypeComparisonInfo(sourceComparisonInfo, useSameIndent) { this.onlyCaptureFirstError = false; this.flags = 0 /* SuccessfulComparison */; this.message = ""; @@ -49310,7 +50713,10 @@ var TypeScript; this.flags = sourceComparisonInfo.flags; this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; this.stringConstantVal = sourceComparisonInfo.stringConstantVal; - this.indent = sourceComparisonInfo.indent + 1; + this.indent = sourceComparisonInfo.indent; + if (!useSameIndent) { + this.indent++; + } } } TypeComparisonInfo.prototype.indentString = function () { @@ -49441,25 +50847,24 @@ var TypeScript; this._resolver = null; this._topLevelDecls = null; this._fileNames = null; - var span = new TypeScript.TextSpan(0, 0); - var globalDecl = new TypeScript.RootPullDecl("", "", 0 /* Global */, 0 /* None */, span, this, false); + var globalDecl = new TypeScript.RootPullDecl("", "", 0 /* Global */, 0 /* None */, this, false); this.documents[0] = new TypeScript.Document(this.compiler, this, "", [], null, 0 /* None */, 0, false, null, globalDecl); - this.anyTypeDecl = new TypeScript.NormalPullDecl("any", "any", 2 /* Primitive */, 0 /* None */, globalDecl, span); - this.booleanTypeDecl = new TypeScript.NormalPullDecl("boolean", "boolean", 2 /* Primitive */, 0 /* None */, globalDecl, span); - this.numberTypeDecl = new TypeScript.NormalPullDecl("number", "number", 2 /* Primitive */, 0 /* None */, globalDecl, span); - this.stringTypeDecl = new TypeScript.NormalPullDecl("string", "string", 2 /* Primitive */, 0 /* None */, globalDecl, span); - this.voidTypeDecl = new TypeScript.NormalPullDecl("void", "void", 2 /* Primitive */, 0 /* None */, globalDecl, span); + this.anyTypeDecl = new TypeScript.NormalPullDecl("any", "any", 2 /* Primitive */, 0 /* None */, globalDecl); + this.booleanTypeDecl = new TypeScript.NormalPullDecl("boolean", "boolean", 2 /* Primitive */, 0 /* None */, globalDecl); + this.numberTypeDecl = new TypeScript.NormalPullDecl("number", "number", 2 /* Primitive */, 0 /* None */, globalDecl); + this.stringTypeDecl = new TypeScript.NormalPullDecl("string", "string", 2 /* Primitive */, 0 /* None */, globalDecl); + this.voidTypeDecl = new TypeScript.NormalPullDecl("void", "void", 2 /* Primitive */, 0 /* None */, globalDecl); - this.nullTypeDecl = new TypeScript.RootPullDecl("null", "", 2 /* Primitive */, 0 /* None */, span, this, false); - this.undefinedTypeDecl = new TypeScript.RootPullDecl("undefined", "", 2 /* Primitive */, 0 /* None */, span, this, false); - this.undefinedValueDecl = new TypeScript.NormalPullDecl("undefined", "undefined", 512 /* Variable */, 8 /* Ambient */, globalDecl, span); + this.nullTypeDecl = new TypeScript.RootPullDecl("null", "", 2 /* Primitive */, 0 /* None */, this, false); + this.undefinedTypeDecl = new TypeScript.RootPullDecl("undefined", "", 2 /* Primitive */, 0 /* None */, this, false); + this.undefinedValueDecl = new TypeScript.NormalPullDecl("undefined", "undefined", 512 /* Variable */, 8 /* Ambient */, globalDecl); this.invalidate(); } SemanticInfoChain.prototype.getDocument = function (fileName) { var document = this.fileNameToDocument[fileName]; - return document ? document : null; + return document || null; }; SemanticInfoChain.prototype.lineMap = function (fileName) { @@ -49505,8 +50910,7 @@ var TypeScript; this.undefinedTypeSymbol = this.addPrimitiveTypeSymbol(this.undefinedTypeDecl); this.undefinedValueSymbol = this.addPrimitiveValueSymbol(this.undefinedValueDecl, this.undefinedTypeSymbol); - var span = new TypeScript.TextSpan(0, 0); - var emptyTypeDecl = new TypeScript.PullSynthesizedDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, null, span, this); + var emptyTypeDecl = new TypeScript.PullSynthesizedDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, null, this); var emptyTypeSymbol = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); emptyTypeDecl.setSymbol(emptyTypeSymbol); emptyTypeSymbol.addDeclaration(emptyTypeDecl); @@ -49567,7 +50971,7 @@ var TypeScript; break; } - if (doNotGoPastThisDecl && topLevelDecl.name == doNotGoPastThisDecl.fileName()) { + if (doNotGoPastThisDecl && topLevelDecl.name === doNotGoPastThisDecl.fileName()) { return null; } } @@ -49604,13 +51008,6 @@ var TypeScript; SemanticInfoChain.prototype.findExternalModule = function (id) { id = TypeScript.normalizePath(id); - var dtsFile = id + ".d.ts"; - var dtsCacheID = this.getDeclPathCacheID([dtsFile], 32 /* DynamicModule */); - var symbol = this.symbolCache[dtsCacheID]; - if (symbol) { - return symbol; - } - var tsFile = id + ".ts"; var tsCacheID = this.getDeclPathCacheID([tsFile], 32 /* DynamicModule */); symbol = this.symbolCache[tsCacheID]; @@ -49618,27 +51015,44 @@ var TypeScript; return symbol; } - symbol = null; + var dtsFile = id + ".d.ts"; + var dtsCacheID = this.getDeclPathCacheID([dtsFile], 32 /* DynamicModule */); + var symbol = this.symbolCache[dtsCacheID]; + if (symbol) { + return symbol; + } + + var dtsSymbol; for (var i = 0; i < this.documents.length; i++) { var document = this.documents[i]; var topLevelDecl = document.topLevelDecl(); if (topLevelDecl.isExternalModule()) { - var isDtsFile = document.fileName == dtsFile; - if (isDtsFile || document.fileName == tsFile) { + var isTsFile = document.fileName === tsFile; + if (isTsFile || document.fileName === dtsFile) { var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; symbol = dynamicModuleDecl.getSymbol(); - this.symbolCache[dtsCacheID] = isDtsFile ? symbol : null; - this.symbolCache[tsCacheID] = !TypeScript.isDTSFile ? symbol : null; - return symbol; + + if (isTsFile) { + this.symbolCache[tsCacheID] = symbol; + + return symbol; + } else { + dtsSymbol = symbol; + } } } } + if (dtsSymbol) { + this.symbolCache[dtsCacheID] = symbol; + return dtsSymbol; + } + this.symbolCache[dtsCacheID] = null; this.symbolCache[tsCacheID] = null; - return symbol; + return null; }; SemanticInfoChain.prototype.findAmbientExternalModuleInGlobalContext = function (id) { @@ -49685,25 +51099,21 @@ var TypeScript; var decls = TypeScript.sentinelEmptyArray; var path; var foundDecls = TypeScript.sentinelEmptyArray; - var keepSearching = (declKind & 164 /* SomeContainer */) || (declKind & 16 /* Interface */); for (var i = 0; i < declPath.length; i++) { path = declPath[i]; decls = TypeScript.sentinelEmptyArray; + var kind = (i === declPath.length - 1) ? declKind : 164 /* SomeContainer */; for (var j = 0; j < declsToSearch.length; j++) { - foundDecls = declsToSearch[j].searchChildDecls(path, declKind); + foundDecls = declsToSearch[j].searchChildDecls(path, kind); for (var k = 0; k < foundDecls.length; k++) { - if (decls == TypeScript.sentinelEmptyArray) { + if (decls === TypeScript.sentinelEmptyArray) { decls = []; } decls[decls.length] = foundDecls[k]; } - - if (foundDecls.length && !keepSearching) { - break; - } } declsToSearch = decls; @@ -49752,9 +51162,20 @@ var TypeScript; var symbol = null; if (decls.length) { - symbol = decls[0].getSymbol(); + var decl = decls[0]; + if (TypeScript.hasFlag(decl.kind, 164 /* SomeContainer */)) { + var valueDecl = decl.getValueDecl(); + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + } + symbol = decl.getSymbol(); if (symbol) { + for (var i = 1; i < decls.length; i++) { + decls[i].ensureSymbolIsBound(); + } + this.symbolCache[cacheID] = symbol; } } @@ -49806,7 +51227,6 @@ var TypeScript; } TypeScript.pullSymbolID = 0; - TypeScript.globalTyvarID = 0; this.resetGlobalSymbols(); @@ -49814,7 +51234,7 @@ var TypeScript; }; SemanticInfoChain.prototype.settingsChangeAffectsSyntax = function (before, after) { - return before.allowAutomaticSemicolonInsertion() !== after.allowAutomaticSemicolonInsertion() || before.codeGenTarget() !== after.codeGenTarget() || before.propagateEnumConstants() != after.propagateEnumConstants(); + return before.allowAutomaticSemicolonInsertion() !== after.allowAutomaticSemicolonInsertion() || before.codeGenTarget() !== after.codeGenTarget() || before.propagateEnumConstants() !== after.propagateEnumConstants(); }; SemanticInfoChain.prototype.setSymbolForAST = function (ast, symbol) { @@ -49822,7 +51242,7 @@ var TypeScript; }; SemanticInfoChain.prototype.getSymbolForAST = function (ast) { - return this.astSymbolMap[ast.syntaxID()]; + return this.astSymbolMap[ast.syntaxID()] || null; }; SemanticInfoChain.prototype.setAliasSymbolForAST = function (ast, symbol) { @@ -49872,7 +51292,7 @@ var TypeScript; SemanticInfoChain.prototype.getDiagnostics = function (fileName) { var diagnostics = this.fileNameToDiagnostics[fileName]; - return diagnostics ? diagnostics : []; + return diagnostics || []; }; SemanticInfoChain.prototype.getBinder = function () { @@ -49902,9 +51322,8 @@ var TypeScript; containingSymbol.addIndexSignature(indexSignature); - var span = TypeScript.TextSpan.fromBounds(ast.start(), ast.end()); - var indexSigDecl = new TypeScript.PullSynthesizedDecl("", "", 4194304 /* IndexSignature */, 2048 /* Signature */, containingDecl, span, containingDecl.semanticInfoChain()); - var indexParamDecl = new TypeScript.PullSynthesizedDecl(indexParamName, indexParamName, 2048 /* Parameter */, 0 /* None */, indexSigDecl, span, containingDecl.semanticInfoChain()); + var indexSigDecl = new TypeScript.PullSynthesizedDecl("", "", 4194304 /* IndexSignature */, 2048 /* Signature */, containingDecl, containingDecl.semanticInfoChain); + var indexParamDecl = new TypeScript.PullSynthesizedDecl(indexParamName, indexParamName, 2048 /* Parameter */, 0 /* None */, indexSigDecl, containingDecl.semanticInfoChain); indexSigDecl.setSignatureSymbol(indexSignature); indexParamDecl.setSymbol(indexParameterSymbol); indexSignature.addDeclaration(indexSigDecl); @@ -49961,14 +51380,28 @@ var TypeScript; return this._topLevelDecls; }; - SemanticInfoChain.prototype.addDiagnosticFromAST = function (ast, diagnosticKey, arguments) { - if (typeof arguments === "undefined") { arguments = null; } - this.addDiagnostic(this.diagnosticFromAST(ast, diagnosticKey, arguments)); + SemanticInfoChain.prototype.addDiagnosticFromAST = function (ast, diagnosticKey, _arguments, additionalLocations) { + if (typeof _arguments === "undefined") { _arguments = null; } + if (typeof additionalLocations === "undefined") { additionalLocations = null; } + this.addDiagnostic(this.diagnosticFromAST(ast, diagnosticKey, _arguments, additionalLocations)); }; - SemanticInfoChain.prototype.diagnosticFromAST = function (ast, diagnosticKey, arguments) { - if (typeof arguments === "undefined") { arguments = null; } - return new TypeScript.Diagnostic(ast.fileName(), this.lineMap(ast.fileName()), ast.start(), ast.width(), diagnosticKey, arguments); + SemanticInfoChain.prototype.diagnosticFromAST = function (ast, diagnosticKey, _arguments, additionalLocations) { + if (typeof _arguments === "undefined") { _arguments = null; } + if (typeof additionalLocations === "undefined") { additionalLocations = null; } + return new TypeScript.Diagnostic(ast.fileName(), this.lineMap(ast.fileName()), ast.start(), ast.width(), diagnosticKey, _arguments, additionalLocations); + }; + + SemanticInfoChain.prototype.locationFromAST = function (ast) { + return new TypeScript.Location(ast.fileName(), this.lineMap(ast.fileName()), ast.start(), ast.width()); + }; + + SemanticInfoChain.prototype.duplicateIdentifierDiagnosticFromAST = function (ast, identifier, additionalLocationAST) { + return this.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Duplicate_identifier_0, [identifier], additionalLocationAST ? [this.locationFromAST(additionalLocationAST)] : null); + }; + + SemanticInfoChain.prototype.addDuplicateIdentifierDiagnosticFromAST = function (ast, identifier, additionalLocationAST) { + this.addDiagnostic(this.duplicateIdentifierDiagnosticFromAST(ast, identifier, additionalLocationAST)); }; return SemanticInfoChain; })(); @@ -50039,7 +51472,6 @@ var TypeScript; function preCollectImportDecls(ast, context) { var importDecl = ast; var declFlags = 0 /* None */; - var span = TypeScript.TextSpan.fromBounds(importDecl.start(), importDecl.end()); var parent = context.getParent(); @@ -50047,19 +51479,17 @@ var TypeScript; declFlags |= 1 /* Exported */; } - var decl = new TypeScript.NormalPullDecl(importDecl.identifier.valueText(), importDecl.identifier.text(), 128 /* TypeAlias */, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(importDecl.identifier.valueText(), importDecl.identifier.text(), 128 /* TypeAlias */, declFlags, parent); context.semanticInfoChain.setDeclForAST(ast, decl); context.semanticInfoChain.setASTForDecl(decl, ast); } function preCollectScriptDecls(sourceUnit, context) { - var span = TypeScript.TextSpan.fromBounds(sourceUnit.start(), sourceUnit.end()); - var fileName = sourceUnit.fileName(); var isExternalModule = context.document.isExternalModule(); - var decl = new TypeScript.RootPullDecl(fileName, fileName, 1 /* Script */, 0 /* None */, span, context.semanticInfoChain, isExternalModule); + var decl = new TypeScript.RootPullDecl(fileName, fileName, 1 /* Script */, 0 /* None */, context.semanticInfoChain, isExternalModule); context.semanticInfoChain.setDeclForAST(sourceUnit, decl); context.semanticInfoChain.setASTForDecl(decl, sourceUnit); @@ -50075,10 +51505,9 @@ var TypeScript; var moduleContainsExecutableCode = containsExecutableCode(sourceUnit.moduleElements); var kind = 32 /* DynamicModule */; - var span = TypeScript.TextSpan.fromBounds(sourceUnit.start(), sourceUnit.end()); var valueText = TypeScript.quoteStr(fileName); - var decl = new TypeScript.NormalPullDecl(valueText, fileName, kind, declFlags, context.getParent(), span); + var decl = new TypeScript.NormalPullDecl(valueText, fileName, kind, declFlags, context.getParent()); context.semanticInfoChain.setASTForDecl(decl, sourceUnit); @@ -50095,7 +51524,6 @@ var TypeScript; function preCollectEnumDecls(enumDecl, context) { var declFlags = 0 /* None */; var enumName = enumDecl.identifier.valueText(); - var kind = 4 /* Container */; if ((TypeScript.hasModifier(enumDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(enumDecl, context)) && !containingModuleHasExportAssignment(enumDecl)) { declFlags |= 1 /* Exported */; @@ -50106,18 +51534,13 @@ var TypeScript; } declFlags |= 4096 /* Enum */; - kind = 64 /* Enum */; + var kind = 64 /* Enum */; - var span = TypeScript.TextSpan.fromBounds(enumDecl.start(), enumDecl.end()); - - var enumDeclaration = new TypeScript.NormalPullDecl(enumName, enumDecl.identifier.text(), kind, declFlags, context.getParent(), span); + var enumDeclaration = new TypeScript.NormalPullDecl(enumName, enumDecl.identifier.text(), kind, declFlags, context.getParent()); context.semanticInfoChain.setDeclForAST(enumDecl, enumDeclaration); context.semanticInfoChain.setASTForDecl(enumDeclaration, enumDecl); - var enumIndexerDecl = new TypeScript.NormalPullDecl("", "", 4194304 /* IndexSignature */, 2048 /* Signature */, enumDeclaration, span); - var enumIndexerParameter = new TypeScript.NormalPullDecl("x", "x", 2048 /* Parameter */, 0 /* None */, enumIndexerDecl, span); - - var valueDecl = new TypeScript.NormalPullDecl(enumDeclaration.name, enumDeclaration.getDisplayName(), 512 /* Variable */, enumDeclaration.flags, context.getParent(), enumDeclaration.getSpan()); + var valueDecl = new TypeScript.NormalPullDecl(enumDeclaration.name, enumDeclaration.getDisplayName(), 512 /* Variable */, enumDeclaration.flags, context.getParent()); enumDeclaration.setValueDecl(valueDecl); context.semanticInfoChain.setASTForDecl(valueDecl, enumDecl); @@ -50127,9 +51550,7 @@ var TypeScript; function createEnumElementDecls(propertyDecl, context) { var parent = context.getParent(); - var span = TypeScript.TextSpan.fromBounds(propertyDecl.start(), propertyDecl.end()); - - var decl = new TypeScript.PullEnumElementDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), parent, span); + var decl = new TypeScript.PullEnumElementDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), parent); context.semanticInfoChain.setDeclForAST(propertyDecl, decl); context.semanticInfoChain.setASTForDecl(decl, propertyDecl); } @@ -50151,13 +51572,11 @@ var TypeScript; var kind = isDynamic ? 32 /* DynamicModule */ : 4 /* Container */; - var span = TypeScript.TextSpan.fromBounds(moduleDecl.start(), moduleDecl.end()); - if (moduleDecl.stringLiteral) { var valueText = TypeScript.quoteStr(moduleDecl.stringLiteral.valueText()); var text = moduleDecl.stringLiteral.text(); - var decl = new TypeScript.NormalPullDecl(valueText, text, kind, declFlags, context.getParent(), span); + var decl = new TypeScript.NormalPullDecl(valueText, text, kind, declFlags, context.getParent()); context.semanticInfoChain.setDeclForAST(moduleDecl, decl); context.semanticInfoChain.setDeclForAST(moduleDecl.stringLiteral, decl); @@ -50178,7 +51597,7 @@ var TypeScript; specificFlags |= 1 /* Exported */; } - var decl = new TypeScript.NormalPullDecl(moduleName.valueText(), moduleName.text(), kind, specificFlags, context.getParent(), span); + var decl = new TypeScript.NormalPullDecl(moduleName.valueText(), moduleName.text(), kind, specificFlags, context.getParent()); context.semanticInfoChain.setDeclForAST(moduleDecl, decl); context.semanticInfoChain.setDeclForAST(moduleName, decl); @@ -50210,7 +51629,7 @@ var TypeScript; function createModuleVariableDecl(decl, moduleNameAST, context) { decl.setFlags(decl.flags | getInitializationFlag(decl)); - var valueDecl = new TypeScript.NormalPullDecl(decl.name, decl.getDisplayName(), 512 /* Variable */, decl.flags, context.getParent(), decl.getSpan()); + var valueDecl = new TypeScript.NormalPullDecl(decl.name, decl.getDisplayName(), 512 /* Variable */, decl.flags, context.getParent()); decl.setValueDecl(valueDecl); context.semanticInfoChain.setASTForDecl(valueDecl, moduleNameAST); } @@ -50225,7 +51644,11 @@ var TypeScript; if (containsExecutableCode(moduleDecl.moduleElements)) { return true; } - } else if (member.kind() !== 128 /* InterfaceDeclaration */ && member.kind() !== 133 /* ImportDeclaration */) { + } else if (member.kind() === 133 /* ImportDeclaration */) { + if (TypeScript.hasModifier(member.modifiers, 1 /* Exported */)) { + return true; + } + } else if (member.kind() !== 128 /* InterfaceDeclaration */) { return true; } } @@ -50235,7 +51658,6 @@ var TypeScript; function preCollectClassDecls(classDecl, context) { var declFlags = 0 /* None */; - var constructorDeclKind = 512 /* Variable */; if ((TypeScript.hasModifier(classDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(classDecl, context)) && !containingModuleHasExportAssignment(classDecl)) { declFlags |= 1 /* Exported */; @@ -50245,12 +51667,11 @@ var TypeScript; declFlags |= 8 /* Ambient */; } - var span = TypeScript.TextSpan.fromBounds(classDecl.start(), classDecl.end()); var parent = context.getParent(); - var decl = new TypeScript.NormalPullDecl(classDecl.identifier.valueText(), classDecl.identifier.text(), 8 /* Class */, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(classDecl.identifier.valueText(), classDecl.identifier.text(), 8 /* Class */, declFlags, parent); - var constructorDecl = new TypeScript.NormalPullDecl(classDecl.identifier.valueText(), classDecl.identifier.text(), constructorDeclKind, declFlags | 16384 /* ClassConstructorVariable */, parent, span); + var constructorDecl = new TypeScript.NormalPullDecl(classDecl.identifier.valueText(), classDecl.identifier.text(), 512 /* Variable */, declFlags | 16384 /* ClassConstructorVariable */, parent); decl.setValueDecl(constructorDecl); @@ -50268,15 +51689,13 @@ var TypeScript; var declFlags = 0 /* None */; - var span = TypeScript.TextSpan.fromBounds(objectType.start(), objectType.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl("", "", 8388608 /* ObjectType */, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl("", "", 8388608 /* ObjectType */, declFlags, parent); context.semanticInfoChain.setDeclForAST(objectType, decl); context.semanticInfoChain.setASTForDecl(decl, objectType); @@ -50290,10 +51709,9 @@ var TypeScript; declFlags |= 1 /* Exported */; } - var span = TypeScript.TextSpan.fromBounds(interfaceDecl.start(), interfaceDecl.end()); var parent = context.getParent(); - var decl = new TypeScript.NormalPullDecl(interfaceDecl.identifier.valueText(), interfaceDecl.identifier.text(), 16 /* Interface */, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(interfaceDecl.identifier.valueText(), interfaceDecl.identifier.text(), 16 /* Interface */, declFlags, parent); context.semanticInfoChain.setDeclForAST(interfaceDecl, decl); context.semanticInfoChain.setASTForDecl(decl, interfaceDecl); @@ -50319,15 +51737,13 @@ var TypeScript; declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var span = TypeScript.TextSpan.fromBounds(argDecl.start(), argDecl.end()); - - var decl = new TypeScript.NormalPullDecl(argDecl.identifier.valueText(), argDecl.identifier.text(), 2048 /* Parameter */, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(argDecl.identifier.valueText(), argDecl.identifier.text(), 2048 /* Parameter */, declFlags, parent); if (argDecl.equalsValueClause) { parent.flags |= 33554432 /* HasDefaultArgs */; } - if (parent.kind == 32768 /* ConstructorMethod */) { + if (parent.kind === 32768 /* ConstructorMethod */) { decl.setFlag(67108864 /* ConstructorParameter */); } @@ -50335,12 +51751,14 @@ var TypeScript; var isInConstructor = parent.kind === 32768 /* ConstructorMethod */; if (isPublicOrPrivate && isInConstructor) { var parentsParent = context.parentChain[context.parentChain.length - 2]; - var propDecl = new TypeScript.NormalPullDecl(argDecl.identifier.valueText(), argDecl.identifier.text(), 4096 /* Property */, declFlags, parentsParent, span); + + var propDeclFlags = declFlags & ~128 /* Optional */; + var propDecl = new TypeScript.NormalPullDecl(argDecl.identifier.valueText(), argDecl.identifier.text(), 4096 /* Property */, propDeclFlags, parentsParent); propDecl.setValueDecl(decl); decl.setFlag(8388608 /* PropertyParameter */); propDecl.setFlag(8388608 /* PropertyParameter */); - if (parent.kind == 32768 /* ConstructorMethod */) { + if (parent.kind === 32768 /* ConstructorMethod */) { propDecl.setFlag(67108864 /* ConstructorParameter */); } @@ -50358,15 +51776,13 @@ var TypeScript; function preCollectTypeParameterDecl(typeParameterDecl, context) { var declFlags = 0 /* None */; - var span = TypeScript.TextSpan.fromBounds(typeParameterDecl.start(), typeParameterDecl.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl(typeParameterDecl.identifier.valueText(), typeParameterDecl.identifier.text(), 8192 /* TypeParameter */, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(typeParameterDecl.identifier.valueText(), typeParameterDecl.identifier.text(), 8192 /* TypeParameter */, declFlags, parent); context.semanticInfoChain.setASTForDecl(decl, typeParameterDecl); context.semanticInfoChain.setDeclForAST(typeParameterDecl, decl); } @@ -50380,9 +51796,7 @@ var TypeScript; declFlags |= 128 /* Optional */; } - var span = TypeScript.TextSpan.fromBounds(propertyDecl.start(), propertyDecl.end()); - - var decl = new TypeScript.NormalPullDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(propertyDecl, decl); context.semanticInfoChain.setASTForDecl(decl, propertyDecl); } @@ -50401,10 +51815,9 @@ var TypeScript; declFlags |= 16 /* Static */; } - var span = TypeScript.TextSpan.fromBounds(memberDecl.start(), memberDecl.end()); var parent = context.getParent(); - var decl = new TypeScript.NormalPullDecl(memberDecl.variableDeclarator.propertyName.valueText(), memberDecl.variableDeclarator.propertyName.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(memberDecl.variableDeclarator.propertyName.valueText(), memberDecl.variableDeclarator.propertyName.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(memberDecl, decl); context.semanticInfoChain.setDeclForAST(memberDecl.variableDeclarator, decl); context.semanticInfoChain.setASTForDecl(decl, memberDecl); @@ -50414,7 +51827,7 @@ var TypeScript; var declFlags = 0 /* None */; var declType = 512 /* Variable */; - var modifiers = TypeScript.getVariableDeclaratorModifiers(varDecl); + var modifiers = TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl); if ((TypeScript.hasModifier(modifiers, 1 /* Exported */) || isParsingAmbientModule(varDecl, context)) && !containingModuleHasExportAssignment(varDecl)) { declFlags |= 1 /* Exported */; } @@ -50423,15 +51836,13 @@ var TypeScript; declFlags |= 8 /* Ambient */; } - var span = TypeScript.TextSpan.fromBounds(varDecl.start(), varDecl.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl(varDecl.propertyName.valueText(), varDecl.propertyName.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(varDecl.propertyName.valueText(), varDecl.propertyName.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(varDecl, decl); context.semanticInfoChain.setASTForDecl(decl, varDecl); @@ -50453,15 +51864,13 @@ var TypeScript; var declFlags = 2048 /* Signature */; var declType = 16777216 /* FunctionType */; - var span = TypeScript.TextSpan.fromBounds(functionTypeDeclAST.start(), functionTypeDeclAST.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(functionTypeDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, functionTypeDeclAST); @@ -50472,15 +51881,13 @@ var TypeScript; var declFlags = 0 /* None */; var declType = 33554432 /* ConstructorType */; - var span = TypeScript.TextSpan.fromBounds(constructorTypeDeclAST.start(), constructorTypeDeclAST.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(constructorTypeDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, constructorTypeDeclAST); @@ -50503,15 +51910,13 @@ var TypeScript; declFlags |= 2048 /* Signature */; } - var span = TypeScript.TextSpan.fromBounds(funcDeclAST.start(), funcDeclAST.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl(funcDeclAST.identifier.valueText(), funcDeclAST.identifier.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(funcDeclAST.identifier.valueText(), funcDeclAST.identifier.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(funcDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, funcDeclAST); @@ -50526,8 +51931,6 @@ var TypeScript; declFlags |= 8192 /* ArrowFunction */; } - var span = TypeScript.TextSpan.fromBounds(functionExpressionDeclAST.start(), functionExpressionDeclAST.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { @@ -50536,7 +51939,7 @@ var TypeScript; var name = id ? id.text() : ""; var displayNameText = displayName ? displayName.text() : ""; - var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, parent, span, displayNameText); + var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, parent, displayNameText); context.semanticInfoChain.setDeclForAST(functionExpressionDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, functionExpressionDeclAST); @@ -50552,9 +51955,7 @@ var TypeScript; declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var span = TypeScript.TextSpan.fromBounds(simpleArrow.identifier.start(), simpleArrow.identifier.end()); - - var decl = new TypeScript.NormalPullDecl(simpleArrow.identifier.valueText(), simpleArrow.identifier.text(), 2048 /* Parameter */, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(simpleArrow.identifier.valueText(), simpleArrow.identifier.text(), 2048 /* Parameter */, declFlags, parent); context.semanticInfoChain.setASTForDecl(decl, simpleArrow.identifier); context.semanticInfoChain.setDeclForAST(simpleArrow.identifier, decl); @@ -50581,10 +51982,9 @@ var TypeScript; declFlags |= 2048 /* Signature */; } - var span = TypeScript.TextSpan.fromBounds(funcDecl.start(), funcDecl.end()); var parent = context.getParent(); - var decl = new TypeScript.NormalPullDecl(funcDecl.propertyName.valueText(), funcDecl.propertyName.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(funcDecl.propertyName.valueText(), funcDecl.propertyName.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(funcDecl, decl); context.semanticInfoChain.setASTForDecl(decl, funcDecl); @@ -50595,11 +51995,9 @@ var TypeScript; var declFlags = 2048 /* Signature */; var declType = 4194304 /* IndexSignature */; - var span = TypeScript.TextSpan.fromBounds(indexSignatureDeclAST.start(), indexSignatureDeclAST.end()); - var parent = context.getParent(); - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(indexSignatureDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, indexSignatureDeclAST); @@ -50616,15 +52014,13 @@ var TypeScript; var declFlags = 2048 /* Signature */; var declType = 1048576 /* CallSignature */; - var span = TypeScript.TextSpan.fromBounds(callSignature.start(), callSignature.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(callSignature, decl); context.semanticInfoChain.setASTForDecl(decl, callSignature); @@ -50642,10 +52038,9 @@ var TypeScript; declFlags |= 128 /* Optional */; } - var span = TypeScript.TextSpan.fromBounds(method.start(), method.end()); var parent = context.getParent(); - var decl = new TypeScript.NormalPullDecl(method.propertyName.valueText(), method.propertyName.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(method.propertyName.valueText(), method.propertyName.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(method, decl); context.semanticInfoChain.setASTForDecl(decl, method); @@ -50656,15 +52051,13 @@ var TypeScript; var declFlags = 2048 /* Signature */; var declType = 2097152 /* ConstructSignature */; - var span = TypeScript.TextSpan.fromBounds(constructSignatureDeclAST.start(), constructSignatureDeclAST.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(constructSignatureDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, constructSignatureDeclAST); @@ -50679,8 +52072,6 @@ var TypeScript; declFlags |= 2048 /* Signature */; } - var span = TypeScript.TextSpan.fromBounds(constructorDeclAST.start(), constructorDeclAST.end()); - var parent = context.getParent(); if (parent) { @@ -50691,7 +52082,7 @@ var TypeScript; } } - var decl = new TypeScript.NormalPullDecl(parent.name, parent.getDisplayName(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(parent.name, parent.getDisplayName(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(constructorDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, constructorDeclAST); @@ -50712,15 +52103,13 @@ var TypeScript; declFlags |= 4 /* Public */; } - var span = TypeScript.TextSpan.fromBounds(getAccessorDeclAST.start(), getAccessorDeclAST.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl(getAccessorDeclAST.propertyName.valueText(), getAccessorDeclAST.propertyName.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(getAccessorDeclAST.propertyName.valueText(), getAccessorDeclAST.propertyName.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(getAccessorDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, getAccessorDeclAST); @@ -50745,15 +52134,13 @@ var TypeScript; declFlags |= 4 /* Public */; } - var span = TypeScript.TextSpan.fromBounds(setAccessorDeclAST.start(), setAccessorDeclAST.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl(setAccessorDeclAST.propertyName.valueText(), setAccessorDeclAST.propertyName.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(setAccessorDeclAST.propertyName.valueText(), setAccessorDeclAST.propertyName.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(setAccessorDeclAST, decl); context.semanticInfoChain.setASTForDecl(decl, setAccessorDeclAST); @@ -50764,15 +52151,13 @@ var TypeScript; var declFlags = 0 /* None */; var declType = 268435456 /* CatchBlock */; - var span = TypeScript.TextSpan.fromBounds(ast.start(), ast.end()); - var parent = context.getParent(); if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(ast, decl); context.semanticInfoChain.setASTForDecl(decl, ast); @@ -50781,15 +52166,13 @@ var TypeScript; var declFlags = 0 /* None */; var declType = 1024 /* CatchVariable */; - var span = TypeScript.TextSpan.fromBounds(ast.identifier.start(), ast.identifier.end()); - var parent = context.getParent(); if (TypeScript.hasFlag(parent.flags, 2097152 /* DeclaredInAWithBlock */)) { declFlags |= 2097152 /* DeclaredInAWithBlock */; } - var decl = new TypeScript.NormalPullDecl(ast.identifier.valueText(), ast.identifier.text(), declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl(ast.identifier.valueText(), ast.identifier.text(), declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(ast.identifier, decl); context.semanticInfoChain.setASTForDecl(decl, ast.identifier); @@ -50802,11 +52185,9 @@ var TypeScript; var declFlags = 0 /* None */; var declType = 134217728 /* WithBlock */; - var span = TypeScript.TextSpan.fromBounds(ast.start(), ast.end()); - var parent = context.getParent(); - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent, span); + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); context.semanticInfoChain.setDeclForAST(ast, decl); context.semanticInfoChain.setASTForDecl(decl, ast); @@ -50814,8 +52195,7 @@ var TypeScript; } function preCollectObjectLiteralDecls(ast, context) { - var span = TypeScript.TextSpan.fromBounds(ast.start(), ast.end()); - var decl = new TypeScript.NormalPullDecl("", "", 256 /* ObjectLiteral */, 0 /* None */, context.getParent(), span); + var decl = new TypeScript.NormalPullDecl("", "", 256 /* ObjectLiteral */, 0 /* None */, context.getParent()); context.semanticInfoChain.setDeclForAST(ast, decl); context.semanticInfoChain.setASTForDecl(decl, ast); @@ -50827,7 +52207,7 @@ var TypeScript; var assignmentText = TypeScript.getPropertyAssignmentNameTextFromIdentifier(propertyAssignment.propertyName); var span = TypeScript.TextSpan.fromBounds(propertyAssignment.start(), propertyAssignment.end()); - var decl = new TypeScript.NormalPullDecl(assignmentText.memberName, assignmentText.actualText, 4096 /* Property */, 4 /* Public */, context.getParent(), span); + var decl = new TypeScript.NormalPullDecl(assignmentText.memberName, assignmentText.actualText, 4096 /* Property */, 4 /* Public */, context.getParent()); context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); @@ -50835,9 +52215,8 @@ var TypeScript; function preCollectFunctionPropertyAssignmentDecls(propertyAssignment, context) { var assignmentText = TypeScript.getPropertyAssignmentNameTextFromIdentifier(propertyAssignment.propertyName); - var span = TypeScript.TextSpan.fromBounds(propertyAssignment.start(), propertyAssignment.end()); - var decl = new TypeScript.NormalPullDecl(assignmentText.memberName, assignmentText.actualText, 4096 /* Property */, 4 /* Public */, context.getParent(), span); + var decl = new TypeScript.NormalPullDecl(assignmentText.memberName, assignmentText.actualText, 4096 /* Property */, 4 /* Public */, context.getParent()); context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); @@ -51043,7 +52422,7 @@ var TypeScript; function computeEnumElementConstantValue(expression, enumMemberDecls, context) { TypeScript.Debug.assert(expression); - if (TypeScript.isIntegerLiteralAST(expression)) { + if (TypeScript.ASTHelpers.isIntegerLiteralAST(expression)) { var token; switch (expression.kind()) { case 164 /* PlusExpression */: @@ -51111,12 +52490,13 @@ var TypeScript; function PullSymbolBinder(semanticInfoChain) { this.semanticInfoChain = semanticInfoChain; this.declsBeingBound = []; + this.inBindingOtherDeclsWalker = new TypeScript.PullHelpers.OtherPullDeclsWalker(); } PullSymbolBinder.prototype.getParent = function (decl, returnInstanceType) { if (typeof returnInstanceType === "undefined") { returnInstanceType = false; } var parentDecl = decl.getParentDecl(); - if (parentDecl.kind == 1 /* Script */) { + if (parentDecl.kind === 1 /* Script */) { return null; } @@ -51129,9 +52509,9 @@ var TypeScript; parent = parentDecl.getSymbol(); if (parent) { var parentDeclKind = parentDecl.kind; - if (parentDeclKind == 262144 /* GetAccessor */) { + if (parentDeclKind === 262144 /* GetAccessor */) { parent = parent.getGetter(); - } else if (parentDeclKind == 524288 /* SetAccessor */) { + } else if (parentDeclKind === 524288 /* SetAccessor */) { parent = parent.getSetter(); } } @@ -51175,7 +52555,7 @@ var TypeScript; PullSymbolBinder.prototype.getExistingSymbol = function (decl, searchKind, parent) { var lookingForValue = (searchKind & 68147712 /* SomeValue */) !== 0; - var lookingForType = (searchKind & 58728539 /* SomeType */) !== 0; + var lookingForType = (searchKind & 58728795 /* SomeType */) !== 0; var lookingForContainer = (searchKind & 164 /* SomeContainer */) !== 0; var name = decl.name; if (parent) { @@ -51232,7 +52612,7 @@ var TypeScript; var isExported = (decl.flags & 1 /* Exported */) !== 0; var prevDecls = prevSymbol.getDeclarations(); var prevIsExported = (prevDecls[prevDecls.length - 1].flags & 1 /* Exported */) !== 0; - if ((isExported !== prevIsExported) && !prevSymbol.isSignature() && (decl.kind & 7340032 /* SomeSignature */) == 0) { + if ((isExported !== prevIsExported) && !prevSymbol.isSignature() && (decl.kind & 7340032 /* SomeSignature */) === 0) { if (reportError) { var ast = this.semanticInfoChain.getASTForDecl(decl); this.semanticInfoChain.addDiagnosticFromAST(ast, TypeScript.DiagnosticCode.All_declarations_of_merged_declaration_0_must_be_exported_or_not_exported, [decl.getDisplayName()]); @@ -51243,6 +52623,16 @@ var TypeScript; return true; }; + PullSymbolBinder.prototype.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList = function (signature, currentSignatures) { + var signatureDecl = signature.getDeclarations()[0]; + TypeScript.Debug.assert(signatureDecl); + var enclosingDecl = signatureDecl.getParentDecl(); + var indexToInsert = TypeScript.ArrayUtilities.indexOf(currentSignatures, function (someSignature) { + return someSignature.getDeclarations()[0].getParentDecl() !== enclosingDecl; + }); + return indexToInsert < 0 ? currentSignatures.length : indexToInsert; + }; + PullSymbolBinder.prototype.bindEnumDeclarationToPullSymbol = function (enumContainerDecl) { var enumName = enumContainerDecl.name; @@ -51260,7 +52650,6 @@ var TypeScript; var enumAST = this.semanticInfoChain.getASTForDecl(enumContainerDecl); var isExported = enumContainerDecl.flags & 1 /* Exported */; - var isInitializedModule = (enumContainerDecl.flags & 102400 /* SomeInitializedModule */) != 0; var createdNewSymbol = false; @@ -51268,9 +52657,7 @@ var TypeScript; if (enumContainerSymbol) { if (enumContainerSymbol.kind !== enumDeclKind) { - if (isInitializedModule) { - this.semanticInfoChain.addDiagnosticFromAST(enumAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [enumContainerDecl.getDisplayName()]); - } + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(enumAST.identifier, enumContainerDecl.getDisplayName(), enumContainerSymbol.getDeclarations()[0].ast()); enumContainerSymbol = null; } else if (!this.checkThatExportsMatch(enumContainerDecl, enumContainerSymbol)) { enumContainerSymbol = null; @@ -51294,7 +52681,7 @@ var TypeScript; this.semanticInfoChain.setSymbolForAST(enumAST.identifier, enumContainerSymbol); this.semanticInfoChain.setSymbolForAST(enumAST, enumContainerSymbol); - if (!enumInstanceSymbol && isInitializedModule) { + if (!enumInstanceSymbol) { var variableSymbol = null; if (parentInstanceSymbol) { if (isExported) { @@ -51327,11 +52714,11 @@ var TypeScript; var augmentedDecl = null; for (var i = 0; i < siblingDecls.length; i++) { - if (siblingDecls[i] == enumContainerDecl) { + if (siblingDecls[i] === enumContainerDecl) { break; } - if ((siblingDecls[i].name == enumName) && (siblingDecls[i].kind & 68147712 /* SomeValue */)) { + if ((siblingDecls[i].name === enumName) && (siblingDecls[i].kind & 68147712 /* SomeValue */)) { augmentedDecl = siblingDecls[i]; break; } @@ -51371,20 +52758,6 @@ var TypeScript; } } - var moduleDeclarations = enumContainerSymbol.getDeclarations(); - - if (moduleDeclarations.length > 1 && enumAST.enumElements.nonSeparatorCount() > 0) { - var multipleEnums = TypeScript.ArrayUtilities.where(moduleDeclarations, function (d) { - return d.kind === 64 /* Enum */; - }).length > 1; - if (multipleEnums) { - var firstVariable = enumAST.enumElements.nonSeparatorAt(0); - if (!firstVariable.equalsValueClause) { - this.semanticInfoChain.addDiagnosticFromAST(firstVariable, TypeScript.DiagnosticCode.Enums_with_multiple_declarations_must_provide_an_initializer_for_the_first_enum_element, null); - } - } - } - if (createdNewSymbol && parent) { if (enumContainerDecl.flags & 1 /* Exported */) { parent.addEnclosedMemberType(enumContainerSymbol); @@ -51393,65 +52766,111 @@ var TypeScript; } } - this.bindEnumIndexerDeclsToPullSymbols(enumContainerDecl, enumContainerSymbol); - + if (createdNewSymbol) { + this.bindEnumIndexerDeclsToPullSymbols(enumContainerSymbol); + } var valueDecl = enumContainerDecl.getValueDecl(); if (valueDecl) { valueDecl.ensureSymbolIsBound(); } - - var otherDecls = this.findDeclsInContext(enumContainerDecl, enumContainerDecl.kind, true); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } }; - PullSymbolBinder.prototype.bindEnumIndexerDeclsToPullSymbols = function (enumContainerDecl, enumContainerSymbol) { - var indexSigDecl = enumContainerDecl.getChildDecls().filter(function (decl) { - return decl.kind == 4194304 /* IndexSignature */; - })[0]; - var indexParamDecl = indexSigDecl.getChildDecls()[0]; - - var syntheticIndexerParameterSymbol = new TypeScript.PullSymbol(indexParamDecl.name, 2048 /* Parameter */); + PullSymbolBinder.prototype.bindEnumIndexerDeclsToPullSymbols = function (enumContainerSymbol) { + var enumContainerInstanceTypeSymbol = enumContainerSymbol.getInstanceSymbol().type; + var syntheticIndexerParameterSymbol = new TypeScript.PullSymbol("x", 2048 /* Parameter */); syntheticIndexerParameterSymbol.type = this.semanticInfoChain.numberTypeSymbol; syntheticIndexerParameterSymbol.setResolved(); + syntheticIndexerParameterSymbol.setIsSynthesized(); var syntheticIndexerSignatureSymbol = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); syntheticIndexerSignatureSymbol.addParameter(syntheticIndexerParameterSymbol); syntheticIndexerSignatureSymbol.returnType = this.semanticInfoChain.stringTypeSymbol; syntheticIndexerSignatureSymbol.setResolved(); + syntheticIndexerSignatureSymbol.setIsSynthesized(); - var enumContainerInstanceTypeSymbol = enumContainerSymbol.getInstanceSymbol().type; enumContainerInstanceTypeSymbol.addIndexSignature(syntheticIndexerSignatureSymbol); + }; - indexSigDecl.setSignatureSymbol(syntheticIndexerSignatureSymbol); - indexParamDecl.setSymbol(syntheticIndexerParameterSymbol); + PullSymbolBinder.prototype.findExistingVariableSymbolForModuleValueDecl = function (decl) { + var isExported = TypeScript.hasFlag(decl.flags, 1 /* Exported */); + var modName = decl.name; + var parentInstanceSymbol = this.getParent(decl, true); + var parentDecl = decl.getParentDecl(); - syntheticIndexerSignatureSymbol.addDeclaration(indexSigDecl); - syntheticIndexerParameterSymbol.addDeclaration(indexParamDecl); + var variableSymbol = null; + + if (parentInstanceSymbol) { + if (isExported) { + variableSymbol = parentInstanceSymbol.findMember(modName, false); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findContainedNonMember(modName); + } + } else { + variableSymbol = parentInstanceSymbol.findContainedNonMember(modName); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findMember(modName, false); + } + } + + if (variableSymbol) { + var declarations = variableSymbol.getDeclarations(); + + if (declarations.length) { + var variableSymbolParentDecl = declarations[0].getParentDecl(); + var isExportedOrHasTheSameParent = isExported || (parentDecl === variableSymbolParentDecl); + + var canReuseVariableSymbol = isExportedOrHasTheSameParent && this.checkThatExportsMatch(decl, variableSymbol, false); + + if (!canReuseVariableSymbol) { + variableSymbol = null; + } + } + } + } else if (!isExported) { + var siblingDecls = parentDecl.getChildDecls(); + + for (var i = 0; i < siblingDecls.length; i++) { + var sibling = siblingDecls[i]; + + var siblingIsSomeValue = TypeScript.hasFlag(sibling.kind, 68147712 /* SomeValue */); + var siblingIsFunctionOrHasImplictVarFlag = TypeScript.hasFlag(sibling.kind, 1032192 /* SomeFunction */) || TypeScript.hasFlag(sibling.flags, 118784 /* ImplicitVariable */); + + var isSiblingAnAugmentableVariable = sibling !== decl && sibling !== decl.getValueDecl() && sibling.name === modName && siblingIsSomeValue && siblingIsFunctionOrHasImplictVarFlag; + + if (isSiblingAnAugmentableVariable) { + if (sibling.hasSymbol()) { + variableSymbol = sibling.getSymbol(); + if (variableSymbol.isContainer()) { + variableSymbol = variableSymbol.getInstanceSymbol(); + } else if (variableSymbol && variableSymbol.isType()) { + variableSymbol = variableSymbol.getConstructorMethod(); + } + + break; + } + } + } + } + return variableSymbol; }; PullSymbolBinder.prototype.bindModuleDeclarationToPullSymbol = function (moduleContainerDecl) { var modName = moduleContainerDecl.name; var moduleContainerTypeSymbol = null; - var moduleInstanceSymbol = null; - var moduleInstanceTypeSymbol = null; - var moduleKind = moduleContainerDecl.kind; var parent = this.getParent(moduleContainerDecl); var parentInstanceSymbol = this.getParent(moduleContainerDecl, true); var parentDecl = moduleContainerDecl.getParentDecl(); var moduleNameAST = this.semanticInfoChain.getASTForDecl(moduleContainerDecl); - var moduleDeclAST = TypeScript.getEnclosingModuleDeclaration(moduleNameAST); + var moduleDeclAST = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(moduleNameAST); if (!moduleDeclAST) { - TypeScript.Debug.assert(moduleContainerDecl.kind === 32 /* DynamicModule */); + TypeScript.Debug.assert(moduleKind === 32 /* DynamicModule */); TypeScript.Debug.assert(moduleNameAST.kind() === 120 /* SourceUnit */); moduleDeclAST = moduleNameAST; @@ -51459,9 +52878,9 @@ var TypeScript; var isExported = TypeScript.hasFlag(moduleContainerDecl.flags, 1 /* Exported */); var searchKind = 164 /* SomeContainer */; - var isInitializedModule = (moduleContainerDecl.flags & 102400 /* SomeInitializedModule */) != 0; + var isInitializedModule = (moduleContainerDecl.flags & 102400 /* SomeInitializedModule */) !== 0; - if (parent && moduleKind == 32 /* DynamicModule */) { + if (parent && moduleKind === 32 /* DynamicModule */) { this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Ambient_external_module_declaration_must_be_defined_in_global_context, null); } @@ -51472,20 +52891,18 @@ var TypeScript; if (moduleContainerTypeSymbol) { if (moduleContainerTypeSymbol.kind !== moduleKind) { if (isInitializedModule) { - this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [moduleContainerDecl.getDisplayName()]); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(moduleNameAST, moduleContainerDecl.getDisplayName(), moduleContainerTypeSymbol.getDeclarations()[0].ast()); } moduleContainerTypeSymbol = null; - } else if (moduleKind == 32 /* DynamicModule */) { + } else if (moduleKind === 32 /* DynamicModule */) { this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Ambient_external_module_declaration_cannot_be_reopened); } else if (!this.checkThatExportsMatch(moduleContainerDecl, moduleContainerTypeSymbol)) { moduleContainerTypeSymbol = null; } } - if (moduleContainerTypeSymbol) { - moduleInstanceSymbol = moduleContainerTypeSymbol.getInstanceSymbol(); - } else { + if (!moduleContainerTypeSymbol) { moduleContainerTypeSymbol = new TypeScript.PullContainerSymbol(modName, moduleKind); createdNewSymbol = true; @@ -51500,74 +52917,7 @@ var TypeScript; this.semanticInfoChain.setSymbolForAST(moduleNameAST, moduleContainerTypeSymbol); this.semanticInfoChain.setSymbolForAST(moduleDeclAST, moduleContainerTypeSymbol); - if (!moduleInstanceSymbol && isInitializedModule) { - var variableSymbol = null; - if (parentInstanceSymbol) { - if (isExported) { - variableSymbol = parentInstanceSymbol.findMember(modName, false); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findContainedNonMember(modName); - } - } else { - variableSymbol = parentInstanceSymbol.findContainedNonMember(modName); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findMember(modName, false); - } - } - - if (variableSymbol) { - var declarations = variableSymbol.getDeclarations(); - - if (declarations.length) { - var variableSymbolParentDecl = declarations[0].getParentDecl(); - - if (parentDecl !== variableSymbolParentDecl) { - variableSymbol = null; - } - } - } - } else if (!isExported) { - var siblingDecls = parentDecl.getChildDecls(); - - for (var i = 0; i < siblingDecls.length; i++) { - var sibling = siblingDecls[i]; - if (sibling !== moduleContainerDecl && sibling.name === modName && TypeScript.hasFlag(sibling.kind, 68147712 /* SomeValue */)) { - if (sibling.hasSymbol()) { - variableSymbol = sibling.getSymbol(); - if (variableSymbol.isContainer()) { - variableSymbol = variableSymbol.getInstanceSymbol(); - } else if (variableSymbol && variableSymbol.isType()) { - variableSymbol = variableSymbol.getConstructorMethod(); - } - - break; - } - } - } - } - - if (variableSymbol) { - moduleInstanceSymbol = variableSymbol; - moduleInstanceTypeSymbol = variableSymbol.type; - } else { - moduleInstanceSymbol = new TypeScript.PullSymbol(modName, 512 /* Variable */); - } - - moduleContainerTypeSymbol.setInstanceSymbol(moduleInstanceSymbol); - - if (!moduleInstanceTypeSymbol) { - moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - moduleInstanceSymbol.type = moduleInstanceTypeSymbol; - } - - moduleInstanceTypeSymbol.addDeclaration(moduleContainerDecl); - - if (!moduleInstanceTypeSymbol.getAssociatedContainerType()) { - moduleInstanceTypeSymbol.setAssociatedContainerType(moduleContainerTypeSymbol); - } - } + var currentModuleValueDecl = moduleContainerDecl.getValueDecl(); var moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); @@ -51581,24 +52931,29 @@ var TypeScript; } } - var valueDecl = moduleContainerDecl.getValueDecl(); + if (currentModuleValueDecl) { + currentModuleValueDecl.ensureSymbolIsBound(); - if (valueDecl) { - valueDecl.ensureSymbolIsBound(); - - if (!valueDecl.hasSymbol()) { - valueDecl.setSymbol(moduleInstanceSymbol); - if (!moduleInstanceSymbol.hasDeclaration(valueDecl)) { - moduleInstanceSymbol.addDeclaration(valueDecl); + var instanceSymbol = null; + var instanceTypeSymbol = null; + if (currentModuleValueDecl.hasSymbol()) { + instanceSymbol = currentModuleValueDecl.getSymbol(); + } else { + instanceSymbol = new TypeScript.PullSymbol(modName, 512 /* Variable */); + currentModuleValueDecl.setSymbol(instanceSymbol); + if (!instanceSymbol.hasDeclaration(currentModuleValueDecl)) { + instanceSymbol.addDeclaration(currentModuleValueDecl); } } - } - var otherDecls = this.findDeclsInContext(moduleContainerDecl, moduleContainerDecl.kind, true); + if (!instanceSymbol.type) { + instanceSymbol.type = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + } - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); + moduleContainerTypeSymbol.setInstanceSymbol(instanceSymbol); + + if (!instanceSymbol.type.getAssociatedContainerType()) { + instanceSymbol.type.setAssociatedContainerType(moduleContainerTypeSymbol); } } }; @@ -51621,7 +52976,7 @@ var TypeScript; } if (importSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(importDeclAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [importDeclaration.getDisplayName()]); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(importDeclAST, importDeclaration.getDisplayName(), importSymbol.getDeclarations()[0].ast()); importSymbol = null; } @@ -51647,6 +53002,28 @@ var TypeScript; } }; + PullSymbolBinder.prototype.ensurePriorDeclarationsAreBound = function (container, currentDecl) { + if (!container) { + return; + } + + var parentDecls = container.getDeclarations(); + for (var i = 0; i < parentDecls.length; ++i) { + var parentDecl = parentDecls[i]; + var childDecls = parentDecl.getChildDecls(); + for (var j = 0; j < childDecls.length; ++j) { + var childDecl = childDecls[j]; + if (childDecl === currentDecl) { + return; + } + + if (childDecl.name === currentDecl.name) { + childDecl.ensureSymbolIsBound(); + } + } + } + }; + PullSymbolBinder.prototype.bindClassDeclarationToPullSymbol = function (classDecl) { var className = classDecl.name; var classSymbol = null; @@ -51657,19 +53034,20 @@ var TypeScript; var classAST = this.semanticInfoChain.getASTForDecl(classDecl); var parent = this.getParent(classDecl); + + this.ensurePriorDeclarationsAreBound(parent, classDecl); + var parentDecl = classDecl.getParentDecl(); var isExported = classDecl.flags & 1 /* Exported */; var isGeneric = false; - classSymbol = this.getExistingSymbol(classDecl, 58728539 /* SomeType */, parent); + classSymbol = this.getExistingSymbol(classDecl, 58728795 /* SomeType */, parent); if (classSymbol && classSymbol.kind === 16 /* Interface */) { - this.semanticInfoChain.addDiagnosticFromAST(classAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [classDecl.getDisplayName()]); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(classAST.identifier, classDecl.getDisplayName(), classSymbol.getDeclarations()[0].ast()); classSymbol = null; } - var decls; - classSymbol = new TypeScript.PullTypeSymbol(className, 8 /* Class */); if (!parent) { @@ -51691,6 +53069,23 @@ var TypeScript; } } + var typeParameterDecls = classDecl.getTypeParameters(); + + for (var i = 0; i < typeParameterDecls.length; i++) { + var typeParameterSymbol = classSymbol.findTypeParameter(typeParameterDecls[i].name); + + if (typeParameterSymbol) { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterSymbol.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameterSymbol.getName()]); + } + + typeParameterSymbol = new TypeScript.PullTypeParameterSymbol(typeParameterDecls[i].name); + + classSymbol.addTypeParameter(typeParameterSymbol); + typeParameterSymbol.addDeclaration(typeParameterDecls[i]); + typeParameterDecls[i].setSymbol(typeParameterSymbol); + } + constructorSymbol = classSymbol.getConstructorMethod(); constructorTypeSymbol = constructorSymbol ? constructorSymbol.type : null; @@ -51726,32 +53121,13 @@ var TypeScript; constructorTypeSymbol.setAssociatedContainerType(classSymbol); - var typeParameters = classDecl.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = classSymbol.findTypeParameter(typeParameters[i].name); - - if (typeParameter != null) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); - - classSymbol.addTypeParameter(typeParameter); - constructorTypeSymbol.addConstructorTypeParameter(typeParameter); - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - var valueDecl = classDecl.getValueDecl(); if (valueDecl) { valueDecl.ensureSymbolIsBound(); } - this.bindStaticPrototypePropertyOfClass(classSymbol, constructorTypeSymbol); + this.bindStaticPrototypePropertyOfClass(classAST, classSymbol, constructorTypeSymbol); }; PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { @@ -51764,11 +53140,11 @@ var TypeScript; var acceptableSharedKind = 16 /* Interface */; - interfaceSymbol = this.getExistingSymbol(interfaceDecl, 58728539 /* SomeType */, parent); + interfaceSymbol = this.getExistingSymbol(interfaceDecl, 58728795 /* SomeType */, parent); if (interfaceSymbol) { if (!(interfaceSymbol.kind & acceptableSharedKind)) { - this.semanticInfoChain.addDiagnosticFromAST(interfaceAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [interfaceDecl.getDisplayName()]); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(interfaceAST.identifier, interfaceDecl.getDisplayName(), interfaceSymbol.getDeclarations()[0].ast()); interfaceSymbol = null; } else if (!this.checkThatExportsMatch(interfaceDecl, interfaceSymbol)) { interfaceSymbol = null; @@ -51805,7 +53181,7 @@ var TypeScript; typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].name); if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); interfaceSymbol.addTypeParameter(typeParameter); } else { @@ -51826,14 +53202,6 @@ var TypeScript; typeParameter.addDeclaration(typeParameters[i]); typeParameters[i].setSymbol(typeParameter); } - - var otherDecls = this.findDeclsInContext(interfaceDecl, interfaceDecl.kind, true); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } }; PullSymbolBinder.prototype.bindObjectTypeDeclarationToPullSymbol = function (objectDecl) { @@ -51874,9 +53242,7 @@ var TypeScript; signature.addDeclaration(constructorTypeDeclaration); constructorTypeDeclaration.setSignatureSymbol(signature); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(funcDecl.parameterList), constructorTypeSymbol, signature); - - constructorTypeSymbol.addConstructSignature(signature); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), constructorTypeSymbol, signature); var typeParameters = constructorTypeDeclaration.getTypeParameters(); var typeParameter; @@ -51885,9 +53251,9 @@ var TypeScript; typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].name); if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - constructorTypeSymbol.addConstructorTypeParameter(typeParameter); + signature.addTypeParameter(typeParameter); } else { var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); @@ -51896,12 +53262,15 @@ var TypeScript; typeParameter.addDeclaration(typeParameters[i]); typeParameters[i].setSymbol(typeParameter); } + + constructorTypeSymbol.appendConstructSignature(signature); }; PullSymbolBinder.prototype.bindVariableDeclarationToPullSymbol = function (variableDeclaration) { var declFlags = variableDeclaration.flags; var declKind = variableDeclaration.kind; var varDeclAST = this.semanticInfoChain.getASTForDecl(variableDeclaration); + var nameAST = varDeclAST.kind() === 131 /* ClassDeclaration */ ? varDeclAST.identifier : varDeclAST.kind() === 225 /* VariableDeclarator */ ? varDeclAST.propertyName : varDeclAST.kind() === 132 /* EnumDeclaration */ ? varDeclAST.identifier : varDeclAST; var isExported = (declFlags & 1 /* Exported */) !== 0; @@ -51916,12 +53285,15 @@ var TypeScript; var parentDecl = variableDeclaration.getParentDecl(); var isImplicit = (declFlags & 118784 /* ImplicitVariable */) !== 0; - var isModuleValue = (declFlags & (32768 /* InitializedModule */)) != 0; - var isEnumValue = (declFlags & 4096 /* Enum */) != 0; - var isClassConstructorVariable = (declFlags & 16384 /* ClassConstructorVariable */) != 0; - + var isModuleValue = (declFlags & (32768 /* InitializedModule */)) !== 0; + var isEnumValue = (declFlags & 4096 /* Enum */) !== 0; + var isClassConstructorVariable = (declFlags & 16384 /* ClassConstructorVariable */) !== 0; variableSymbol = this.getExistingSymbol(variableDeclaration, 68147712 /* SomeValue */, parent); + if (!variableSymbol && isModuleValue) { + variableSymbol = this.findExistingVariableSymbolForModuleValueDecl(variableDeclaration.getContainerDecl()); + } + if (variableSymbol && !variableSymbol.isType()) { parentHadSymbol = true; } @@ -51937,28 +53309,29 @@ var TypeScript; var prevIsClassConstructorVariable = variableSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */); var prevIsModuleValue = variableSymbol.allDeclsHaveFlag(32768 /* InitializedModule */); var prevIsImplicit = variableSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */); - var prevIsFunction = prevKind == 16384 /* Function */; + var prevIsFunction = TypeScript.ArrayUtilities.any(variableSymbol.getDeclarations(), function (decl) { + return decl.kind === 16384 /* Function */; + }); var prevIsAmbient = variableSymbol.allDeclsHaveFlag(8 /* Ambient */); - var isAmbientOrPrevIsAmbient = prevIsAmbient || (variableDeclaration.flags & 8 /* Ambient */) != 0; + var isAmbientOrPrevIsAmbient = prevIsAmbient || (variableDeclaration.flags & 8 /* Ambient */) !== 0; var prevDecl = variableSymbol.getDeclarations()[0]; var prevParentDecl = prevDecl.getParentDecl(); - var bothAreGlobal = parentDecl && (parentDecl.kind == 1 /* Script */) && (prevParentDecl.kind == 1 /* Script */); - var shareParent = bothAreGlobal || prevDecl.getParentDecl() == variableDeclaration.getParentDecl(); - var prevIsParam = shareParent && prevKind == 2048 /* Parameter */ && declKind == 512 /* Variable */; + var bothAreGlobal = parentDecl && (parentDecl.kind === 1 /* Script */) && (prevParentDecl.kind === 1 /* Script */); + var shareParent = bothAreGlobal || prevDecl.getParentDecl() === variableDeclaration.getParentDecl(); + var prevIsParam = shareParent && prevKind === 2048 /* Parameter */ && declKind == 512 /* Variable */; var acceptableRedeclaration = prevIsParam || (isImplicit && ((!isEnumValue && !isClassConstructorVariable && prevIsFunction) || ((isModuleValue || isEnumValue) && (prevIsModuleValue || prevIsEnum)) || (isClassConstructorVariable && prevIsModuleValue && isAmbientOrPrevIsAmbient) || (isModuleValue && prevIsClassConstructorVariable))); if (acceptableRedeclaration && (prevIsClassConstructorVariable || prevIsFunction) && !isAmbientOrPrevIsAmbient) { - if (prevDecl.fileName() != variableDeclaration.fileName()) { - this.semanticInfoChain.addDiagnostic(TypeScript.diagnosticFromDecl(variableDeclaration, TypeScript.DiagnosticCode.Module_0_cannot_merge_with_previous_declaration_of_1_in_a_different_file_2, [declName, declName, prevDecl.fileName()])); + if (prevDecl.fileName() !== variableDeclaration.fileName()) { + this.semanticInfoChain.addDiagnostic(TypeScript.PullHelpers.diagnosticFromDecl(variableDeclaration, TypeScript.DiagnosticCode.Module_0_cannot_merge_with_previous_declaration_of_1_in_a_different_file_2, [declName, declName, prevDecl.fileName()])); variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); } } if (!acceptableRedeclaration || prevIsParam) { - if (!prevIsParam && (isImplicit || prevIsImplicit || (prevKind & 1032192 /* SomeFunction */) !== 0) || !shareParent) { - var diagnostic = TypeScript.diagnosticFromDecl(variableDeclaration, TypeScript.DiagnosticCode.Duplicate_identifier_0, [variableDeclaration.getDisplayName()]); - this.semanticInfoChain.addDiagnostic(diagnostic); + if (!prevIsParam && (isImplicit || prevIsImplicit || TypeScript.hasFlag(prevKind, 1032192 /* SomeFunction */)) || !shareParent) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(nameAST, variableDeclaration.getDisplayName(), variableSymbol.getDeclarations()[0].ast()); variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); } else { this.checkThatExportsMatch(variableDeclaration, variableSymbol); @@ -51983,7 +53356,7 @@ var TypeScript; variableSymbol.addDeclaration(variableDeclaration); variableDeclaration.setSymbol(variableSymbol); - this.semanticInfoChain.setSymbolForAST(varDeclAST.propertyName, variableSymbol); + this.semanticInfoChain.setSymbolForAST(nameAST, variableSymbol); this.semanticInfoChain.setSymbolForAST(varDeclAST, variableSymbol); } else if (!parentHadSymbol) { if (isClassConstructorVariable) { @@ -52001,22 +53374,10 @@ var TypeScript; } if (!classTypeSymbol) { - var parentDecl = variableDeclaration.getParentDecl(); - - if (parentDecl) { - var childDecls = parentDecl.searchChildDecls(declName, 58728539 /* SomeType */); - - if (childDecls.length) { - for (var i = 0; i < childDecls.length; i++) { - if (childDecls[i].getValueDecl() === variableDeclaration) { - classTypeSymbol = childDecls[i].getSymbol(); - } - } - } - } - + var containerDecl = variableDeclaration.getContainerDecl(); + classTypeSymbol = containerDecl.getSymbol(); if (!classTypeSymbol) { - classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 58728539 /* SomeType */, variableDeclaration); + classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 58728795 /* SomeType */, variableDeclaration); } } @@ -52060,20 +53421,8 @@ var TypeScript; } if (!moduleContainerTypeSymbol) { - var parentDecl = variableDeclaration.getParentDecl(); - - if (parentDecl) { - var searchKind = (declFlags & (32768 /* InitializedModule */ | 65536 /* InitializedDynamicModule */)) ? 164 /* SomeContainer */ : 64 /* Enum */; - var childDecls = parentDecl.searchChildDecls(declName, searchKind); - - if (childDecls.length) { - for (var i = 0; i < childDecls.length; i++) { - if (childDecls[i].getValueDecl() === variableDeclaration) { - moduleContainerTypeSymbol = childDecls[i].getSymbol(); - } - } - } - } + var containerDecl = variableDeclaration.getContainerDecl(); + moduleContainerTypeSymbol = containerDecl.getSymbol(); if (!moduleContainerTypeSymbol) { moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 164 /* SomeContainer */, variableDeclaration); @@ -52089,6 +53438,10 @@ var TypeScript; if (moduleContainerTypeSymbol) { variableSymbol = moduleContainerTypeSymbol.getInstanceSymbol(); + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + variableSymbol.type = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + } if (!variableSymbol.hasDeclaration(variableDeclaration)) { variableSymbol.addDeclaration(variableDeclaration); @@ -52105,6 +53458,11 @@ var TypeScript; variableDeclaration.setSymbol(variableSymbol); } + var containerDecl = variableDeclaration.getContainerDecl(); + if (variableSymbol && variableSymbol.type && containerDecl && !variableSymbol.type.hasDeclaration(containerDecl)) { + variableSymbol.type.addDeclaration(containerDecl); + } + if (parent && !parentHadSymbol) { if (declFlags & 1 /* Exported */) { parent.addMember(variableSymbol); @@ -52112,14 +53470,6 @@ var TypeScript; parent.addEnclosedNonMember(variableSymbol); } } - - var otherDecls = this.findDeclsInContext(variableDeclaration, variableDeclaration.kind, false); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } }; PullSymbolBinder.prototype.bindCatchVariableToPullSymbol = function (variableDeclaration) { @@ -52153,7 +53503,7 @@ var TypeScript; var propertySymbol = parent.findMember(declName, false); if (propertySymbol) { - this.semanticInfoChain.addDiagnostic(TypeScript.diagnosticFromDecl(propertyDeclaration, TypeScript.DiagnosticCode.Duplicate_identifier_0, [propertyDeclaration.getDisplayName()])); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(propDeclAST.propertyName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); } if (propertySymbol) { @@ -52208,7 +53558,7 @@ var TypeScript; propertySymbol = parent.findMember(declName, false); if (propertySymbol) { - this.semanticInfoChain.addDiagnostic(TypeScript.diagnosticFromDecl(propertyDeclaration, TypeScript.DiagnosticCode.Duplicate_identifier_0, [propertyDeclaration.getDisplayName()])); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(astName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); } if (propertySymbol) { @@ -52253,28 +53603,33 @@ var TypeScript; parameterSymbol.isVarArg = true; } - if (decl.flags & 128 /* Optional */) { - parameterSymbol.isOptional = true; - } - if (params[id.valueText()]) { this.semanticInfoChain.addDiagnosticFromAST(argDecl, TypeScript.DiagnosticCode.Duplicate_identifier_0, [id.text()]); } else { params[id.valueText()] = true; } + if (decl) { + var isParameterOptional = false; + if (isProperty) { decl.ensureSymbolIsBound(); var valDecl = decl.getValueDecl(); if (valDecl) { + isParameterOptional = TypeScript.hasFlag(valDecl.flags, 128 /* Optional */); + valDecl.setSymbol(parameterSymbol); parameterSymbol.addDeclaration(valDecl); } } else { + isParameterOptional = TypeScript.hasFlag(decl.flags, 128 /* Optional */); + parameterSymbol.addDeclaration(decl); decl.setSymbol(parameterSymbol); } + + parameterSymbol.isOptional = isParameterOptional; } signatureSymbol.addParameter(parameterSymbol, parameterSymbol.isOptional); @@ -52298,6 +53653,7 @@ var TypeScript; var isSignature = (declFlags & 2048 /* Signature */) !== 0; var parent = this.getParent(functionDeclaration, true); + var parentDecl = functionDeclaration.getParentDecl(); var parentHadSymbol = false; @@ -52307,11 +53663,21 @@ var TypeScript; functionSymbol = this.getExistingSymbol(functionDeclaration, 68147712 /* SomeValue */, parent); if (functionSymbol) { - var previousIsAmbient = functionSymbol.allDeclsHaveFlag(8 /* Ambient */); - var isAmbientOrPreviousIsAmbient = previousIsAmbient || functionDeclaration.flags & 8 /* Ambient */; - var acceptableRedeclaration = functionSymbol.kind === 16384 /* Function */ && (isSignature || functionSymbol.allDeclsHaveFlag(2048 /* Signature */)) || functionSymbol.allDeclsHaveFlag(32768 /* InitializedModule */) && isAmbientOrPreviousIsAmbient; + var acceptableRedeclaration; + + if (functionSymbol.kind === 16384 /* Function */) { + acceptableRedeclaration = isSignature || functionSymbol.allDeclsHaveFlag(2048 /* Signature */); + } else { + var isCurrentDeclAmbient = TypeScript.hasFlag(functionDeclaration.flags, 8 /* Ambient */); + acceptableRedeclaration = TypeScript.ArrayUtilities.all(functionSymbol.getDeclarations(), function (decl) { + var isInitializedModuleOrAmbientDecl = TypeScript.hasFlag(decl.flags, 32768 /* InitializedModule */) && (isCurrentDeclAmbient || TypeScript.hasFlag(decl.flags, 8 /* Ambient */)); + var isSignature = TypeScript.hasFlag(decl.flags, 2048 /* Signature */); + return isInitializedModuleOrAmbientDecl || isSignature; + }); + } + if (!acceptableRedeclaration) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [functionDeclaration.getDisplayName()]); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.identifier, functionDeclaration.getDisplayName(), functionSymbol.getDeclarations()[0].ast()); functionSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(funcName); } } @@ -52346,7 +53712,7 @@ var TypeScript; } } - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); signature.addDeclaration(functionDeclaration); functionDeclaration.setSignatureSymbol(signature); @@ -52356,7 +53722,7 @@ var TypeScript; } var funcDecl = this.semanticInfoChain.getASTForDecl(functionDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList), functionTypeSymbol, signature); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), functionTypeSymbol, signature); var typeParameters = functionDeclaration.getTypeParameters(); var typeParameter; @@ -52365,7 +53731,7 @@ var TypeScript; typeParameter = signature.findTypeParameter(typeParameters[i].name); if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); signature.addTypeParameter(typeParameter); } else { @@ -52377,15 +53743,7 @@ var TypeScript; typeParameters[i].setSymbol(typeParameter); } - functionTypeSymbol.addCallSignature(signature); - - var otherDecls = this.findDeclsInContext(functionDeclaration, functionDeclaration.kind, false); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } + functionTypeSymbol.appendCallSignature(signature); }; PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { @@ -52393,10 +53751,10 @@ var TypeScript; var declFlags = functionExpressionDeclaration.flags; var ast = this.semanticInfoChain.getASTForDecl(functionExpressionDeclaration); - var parameters = ast.kind() === 219 /* SimpleArrowFunctionExpression */ ? TypeScript.Parameters.fromIdentifier(ast.identifier) : TypeScript.Parameters.fromParameterList(TypeScript.getParameterList(ast)); + var parameters = ast.kind() === 219 /* SimpleArrowFunctionExpression */ ? TypeScript.ASTHelpers.parametersFromIdentifier(ast.identifier) : TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(ast)); var funcExpAST = ast; - var functionName = declKind == 131072 /* FunctionExpression */ ? functionExpressionDeclaration.getFunctionExpressionName() : functionExpressionDeclaration.name; + var functionName = declKind === 131072 /* FunctionExpression */ ? functionExpressionDeclaration.getFunctionExpressionName() : functionExpressionDeclaration.name; var functionSymbol = new TypeScript.PullSymbol(functionName, declKind); var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); functionTypeSymbol.setFunctionSymbol(functionSymbol); @@ -52414,7 +53772,7 @@ var TypeScript; this.semanticInfoChain.setSymbolForAST(funcExpAST, functionSymbol); - var signature = new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, true); if (parameters.lastParameterIsRest()) { signature.hasVarArgs = true; @@ -52427,7 +53785,7 @@ var TypeScript; typeParameter = signature.findTypeParameter(typeParameters[i].name); if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); signature.addTypeParameter(typeParameter); } else { @@ -52444,7 +53802,7 @@ var TypeScript; this.bindParameterSymbols(funcExpAST, parameters, functionTypeSymbol, signature); - functionTypeSymbol.addCallSignature(signature); + functionTypeSymbol.appendCallSignature(signature); }; PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { @@ -52459,7 +53817,7 @@ var TypeScript; this.semanticInfoChain.setSymbolForAST(funcTypeAST, functionTypeSymbol); var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); if (TypeScript.lastParameterIsRest(funcTypeAST.parameterList)) { signature.hasVarArgs = true; @@ -52472,7 +53830,7 @@ var TypeScript; typeParameter = signature.findTypeParameter(typeParameters[i].name); if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); signature.addTypeParameter(typeParameter); } else { @@ -52487,9 +53845,9 @@ var TypeScript; signature.addDeclaration(functionTypeDeclaration); functionTypeDeclaration.setSignatureSymbol(signature); - this.bindParameterSymbols(funcTypeAST, TypeScript.Parameters.fromParameterList(funcTypeAST.parameterList), functionTypeSymbol, signature); + this.bindParameterSymbols(funcTypeAST, TypeScript.ASTHelpers.parametersFromParameterList(funcTypeAST.parameterList), functionTypeSymbol, signature); - functionTypeSymbol.addCallSignature(signature); + functionTypeSymbol.appendCallSignature(signature); }; PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { @@ -52518,7 +53876,7 @@ var TypeScript; methodSymbol = parent.findMember(methodName, false); if (methodSymbol && (methodSymbol.kind !== 65536 /* Method */ || (!isSignature && !methodSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { - this.semanticInfoChain.addDiagnosticFromAST(methodAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [methodDeclaration.getDisplayName()]); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(methodAST, methodDeclaration.getDisplayName(), methodSymbol.getDeclarations()[0].ast()); methodSymbol = null; } @@ -52558,9 +53916,9 @@ var TypeScript; var sigKind = 1048576 /* CallSignature */; - var signature = isSignature ? new TypeScript.PullSignatureSymbol(sigKind) : new TypeScript.PullDefinitionSignatureSymbol(sigKind); + var signature = new TypeScript.PullSignatureSymbol(sigKind, !isSignature); - var parameterList = TypeScript.getParameterList(methodAST); + var parameterList = TypeScript.ASTHelpers.getParameterList(methodAST); if (TypeScript.lastParameterIsRest(parameterList)) { signature.hasVarArgs = true; } @@ -52577,7 +53935,7 @@ var TypeScript; typeParameter = signature.findTypeParameter(typeParameterName); if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName, true); + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName); signature.addTypeParameter(typeParameter); } else { this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); @@ -52591,29 +53949,22 @@ var TypeScript; methodDeclaration.setSignatureSymbol(signature); var funcDecl = this.semanticInfoChain.getASTForDecl(methodDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(TypeScript.getParameterList(funcDecl)), methodTypeSymbol, signature); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), methodTypeSymbol, signature); - methodTypeSymbol.addCallSignature(signature); - - var otherDecls = this.findDeclsInContext(methodDeclaration, methodDeclaration.kind, false); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(signature, methodTypeSymbol.getOwnCallSignatures()); + methodTypeSymbol.insertCallSignatureAtIndex(signature, signatureIndex); }; - PullSymbolBinder.prototype.bindStaticPrototypePropertyOfClass = function (classTypeSymbol, constructorTypeSymbol) { + PullSymbolBinder.prototype.bindStaticPrototypePropertyOfClass = function (classAST, classTypeSymbol, constructorTypeSymbol) { var prototypeStr = "prototype"; var prototypeSymbol = constructorTypeSymbol.findMember(prototypeStr, false); if (prototypeSymbol && !prototypeSymbol.getIsSynthesized()) { - this.semanticInfoChain.addDiagnostic(TypeScript.diagnosticFromDecl(prototypeSymbol.getDeclarations()[0], TypeScript.DiagnosticCode.Duplicate_identifier_0, [prototypeSymbol.getDisplayName()])); + this.semanticInfoChain.addDiagnostic(TypeScript.PullHelpers.diagnosticFromDecl(prototypeSymbol.getDeclarations()[0], TypeScript.DiagnosticCode.Duplicate_identifier_0, [prototypeSymbol.getDisplayName()])); } if (!prototypeSymbol || !prototypeSymbol.getIsSynthesized()) { - var prototypeDecl = new TypeScript.PullSynthesizedDecl(prototypeStr, prototypeStr, 4096 /* Property */, 4 /* Public */ | 16 /* Static */, constructorTypeSymbol.getDeclarations()[0], classTypeSymbol.getDeclarations()[0].getSpan(), this.semanticInfoChain); + var prototypeDecl = new TypeScript.PullSynthesizedDecl(prototypeStr, prototypeStr, 4096 /* Property */, 4 /* Public */ | 16 /* Static */, constructorTypeSymbol.getDeclarations()[0], this.semanticInfoChain); prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); prototypeSymbol.setIsSynthesized(); @@ -52679,36 +54030,20 @@ var TypeScript; constructorSymbol.setIsSynthesized(false); this.semanticInfoChain.setSymbolForAST(constructorAST, constructorSymbol); - var constructSignature = isSignature ? new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */) : new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */); - + var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */, !isSignature); constructSignature.returnType = parent; + constructSignature.addTypeParametersFromReturnType(); constructSignature.addDeclaration(constructorDeclaration); constructorDeclaration.setSignatureSymbol(constructSignature); - this.bindParameterSymbols(constructorAST, TypeScript.Parameters.fromParameterList(constructorAST.parameterList), constructorTypeSymbol, constructSignature); + this.bindParameterSymbols(constructorAST, TypeScript.ASTHelpers.parametersFromParameterList(constructorAST.callSignature.parameterList), constructorTypeSymbol, constructSignature); - var typeParameters = constructorTypeSymbol.getTypeParameters(); - - for (var i = 0; i < typeParameters.length; i++) { - constructSignature.addTypeParameter(typeParameters[i]); - } - - if (TypeScript.lastParameterIsRest(constructorAST.parameterList)) { + if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { constructSignature.hasVarArgs = true; } - constructorTypeSymbol.addConstructSignature(constructSignature); - - var otherDecls = this.findDeclsInContext(constructorDeclaration, constructorDeclaration.kind, false); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } - - this.bindStaticPrototypePropertyOfClass(parent, constructorTypeSymbol); + constructorTypeSymbol.appendConstructSignature(constructSignature); }; PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { @@ -52728,7 +54063,7 @@ var TypeScript; typeParameter = constructSignature.findTypeParameter(typeParameters[i].name); if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); constructSignature.addTypeParameter(typeParameter); } else { @@ -52744,11 +54079,12 @@ var TypeScript; constructSignatureDeclaration.setSignatureSymbol(constructSignature); var funcDecl = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(TypeScript.getParameterList(funcDecl)), null, constructSignature); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), null, constructSignature); this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration), constructSignature); - parent.addConstructSignature(constructSignature); + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(constructSignature, parent.getOwnConstructSignatures()); + parent.insertConstructSignatureAtIndex(constructSignature, signatureIndex); }; PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { @@ -52768,7 +54104,7 @@ var TypeScript; typeParameter = callSignature.findTypeParameter(typeParameters[i].name); if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); callSignature.addTypeParameter(typeParameter); } else { @@ -52784,11 +54120,12 @@ var TypeScript; callSignatureDeclaration.setSignatureSymbol(callSignature); var funcDecl = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(funcDecl.parameterList), null, callSignature); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), null, callSignature); this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(callSignatureDeclaration), callSignature); - parent.addCallSignature(callSignature); + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(callSignature, parent.getOwnCallSignatures()); + parent.insertCallSignatureAtIndex(callSignature, signatureIndex); }; PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { @@ -52798,7 +54135,7 @@ var TypeScript; indexSignatureDeclaration.setSignatureSymbol(indexSignature); var funcDecl = this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameter(funcDecl.parameter), null, indexSignature); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter), null, indexSignature); this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration), indexSignature); @@ -52838,7 +54175,7 @@ var TypeScript; if (accessorSymbol) { if (!accessorSymbol.isAccessor()) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [getAccessorDeclaration.getDisplayName()]); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, getAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); accessorSymbol = null; } else { getterSymbol = accessorSymbol.getGetter(); @@ -52885,14 +54222,14 @@ var TypeScript; parent.addMember(accessorSymbol); } - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); signature.addDeclaration(getAccessorDeclaration); getAccessorDeclaration.setSignatureSymbol(signature); - this.bindParameterSymbols(funcDeclAST, TypeScript.Parameters.fromParameterList(funcDeclAST.parameterList), getterTypeSymbol, signature); + this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), getterTypeSymbol, signature); - getterTypeSymbol.addCallSignature(signature); + getterTypeSymbol.appendCallSignature(signature); }; PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { @@ -52926,7 +54263,7 @@ var TypeScript; if (accessorSymbol) { if (!accessorSymbol.isAccessor()) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [setAccessorDeclaration.getDisplayName()]); + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, setAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); accessorSymbol = null; } else { setterSymbol = accessorSymbol.getSetter(); @@ -52973,25 +54310,63 @@ var TypeScript; parent.addMember(accessorSymbol); } - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); signature.addDeclaration(setAccessorDeclaration); setAccessorDeclaration.setSignatureSymbol(signature); - this.bindParameterSymbols(funcDeclAST, TypeScript.Parameters.fromParameterList(funcDeclAST.parameterList), setterTypeSymbol, signature); + this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), setterTypeSymbol, signature); - setterTypeSymbol.addCallSignature(signature); + setterTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.getDeclsToBind = function (decl) { + var decls; + switch (decl.kind) { + case 64 /* Enum */: + case 32 /* DynamicModule */: + case 4 /* Container */: + case 16 /* Interface */: + decls = this.findDeclsInContext(decl, decl.kind, true); + break; + + case 512 /* Variable */: + case 16384 /* Function */: + case 65536 /* Method */: + case 32768 /* ConstructorMethod */: + decls = this.findDeclsInContext(decl, decl.kind, false); + break; + + default: + decls = [decl]; + } + TypeScript.Debug.assert(decls && decls.length > 0); + TypeScript.Debug.assert(TypeScript.ArrayUtilities.contains(decls, decl)); + return decls; + }; + + PullSymbolBinder.prototype.shouldBindDeclaration = function (decl) { + return !decl.hasBeenBound() && this.declsBeingBound.indexOf(decl.declID) < 0; }; PullSymbolBinder.prototype.bindDeclToPullSymbol = function (decl) { - if (decl.hasBeenBound()) { - return; + if (this.shouldBindDeclaration(decl)) { + this.bindAllDeclsToPullSymbol(decl); } + }; - if (this.declsBeingBound.indexOf(decl.declID) >= 0) { - return; + PullSymbolBinder.prototype.bindAllDeclsToPullSymbol = function (askedDecl) { + var allDecls = this.getDeclsToBind(askedDecl); + for (var i = 0; i < allDecls.length; i++) { + var decl = allDecls[i]; + + if (this.shouldBindDeclaration(decl)) { + this.bindSingleDeclToPullSymbol(decl); + } } + }; + PullSymbolBinder.prototype.bindSingleDeclToPullSymbol = function (decl) { this.declsBeingBound.push(decl.declID); switch (decl.kind) { @@ -53110,6 +54485,25 @@ var TypeScript; var TypeScript; (function (TypeScript) { (function (PullHelpers) { + function diagnosticFromDecl(decl, diagnosticKey, _arguments, additionalLocations) { + if (typeof _arguments === "undefined") { _arguments = null; } + if (typeof additionalLocations === "undefined") { additionalLocations = null; } + var ast = decl.ast(); + return decl.semanticInfoChain.diagnosticFromAST(ast, diagnosticKey, _arguments, additionalLocations); + } + PullHelpers.diagnosticFromDecl = diagnosticFromDecl; + + function resolveDeclaredSymbolToUseType(symbol) { + if (symbol.isSignature()) { + if (!symbol.returnType) { + symbol._resolveDeclaredSymbol(); + } + } else if (!symbol.type) { + symbol._resolveDeclaredSymbol(); + } + } + PullHelpers.resolveDeclaredSymbolToUseType = resolveDeclaredSymbolToUseType; + function getSignatureForFuncDecl(functionDecl) { var funcDecl = functionDecl.ast(); var funcSymbol = functionDecl.getSymbol(); @@ -53180,7 +54574,7 @@ var TypeScript; PullHelpers.symbolIsEnum = symbolIsEnum; function symbolIsModule(symbol) { - return symbol && (symbol.kind == 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); + return symbol && (symbol.kind === 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); } PullHelpers.symbolIsModule = symbolIsModule; @@ -53209,7 +54603,7 @@ var TypeScript; b = b.referencedTypeSymbol; } - return a == b; + return a === b; } PullHelpers.typeSymbolsAreIdentical = typeSymbolsAreIdentical; @@ -53217,7 +54611,7 @@ var TypeScript; var rootType = type.getRootSymbol(); while (true) { - if (type == rootType) { + if (type === rootType) { return type; } @@ -53235,7 +54629,7 @@ var TypeScript; return true; } - if (containerKind == 33554432 /* ConstructorType */ && !symbol.anyDeclHasFlag(16 /* Static */)) { + if (containerKind === 33554432 /* ConstructorType */ && !symbol.anyDeclHasFlag(16 /* Static */ | 1 /* Exported */)) { return true; } } @@ -53243,9 +54637,300 @@ var TypeScript; return false; } PullHelpers.isSymbolLocal = isSymbolLocal; + + function isExportedSymbolInClodule(symbol) { + var container = symbol.getContainer(); + return container && container.kind === 33554432 /* ConstructorType */ && symbolIsModule(container) && symbol.anyDeclHasFlag(1 /* Exported */); + } + PullHelpers.isExportedSymbolInClodule = isExportedSymbolInClodule; + + + + function walkSignatureSymbol(signatureSymbol, walker) { + var continueWalk = true; + var parameters = signatureSymbol.parameters; + if (parameters) { + for (var i = 0; continueWalk && i < parameters.length; i++) { + continueWalk = walker.signatureParameterWalk(parameters[i]); + } + } + + if (continueWalk) { + continueWalk = walker.signatureReturnTypeWalk(signatureSymbol.returnType); + } + + return continueWalk; + } + + function walkPullTypeSymbolStructure(typeSymbol, walker) { + var continueWalk = true; + + var members = typeSymbol.getMembers(); + for (var i = 0; continueWalk && i < members.length; i++) { + continueWalk = walker.memberSymbolWalk(members[i]); + } + + if (continueWalk) { + var callSigantures = typeSymbol.getCallSignatures(); + for (var i = 0; continueWalk && i < callSigantures.length; i++) { + continueWalk = walker.callSignatureWalk(callSigantures[i]); + if (continueWalk) { + continueWalk = walkSignatureSymbol(callSigantures[i], walker); + } + } + } + + if (continueWalk) { + var constructSignatures = typeSymbol.getConstructSignatures(); + for (var i = 0; continueWalk && i < constructSignatures.length; i++) { + continueWalk = walker.constructSignatureWalk(constructSignatures[i]); + if (continueWalk) { + continueWalk = walkSignatureSymbol(constructSignatures[i], walker); + } + } + } + + if (continueWalk) { + var indexSignatures = typeSymbol.getIndexSignatures(); + for (var i = 0; continueWalk && i < indexSignatures.length; i++) { + continueWalk = walker.indexSignatureWalk(indexSignatures[i]); + if (continueWalk) { + continueWalk = walkSignatureSymbol(indexSignatures[i], walker); + } + } + } + } + PullHelpers.walkPullTypeSymbolStructure = walkPullTypeSymbolStructure; + + var OtherPullDeclsWalker = (function () { + function OtherPullDeclsWalker() { + this.currentlyWalkingOtherDecls = []; + } + OtherPullDeclsWalker.prototype.walkOtherPullDecls = function (currentDecl, otherDecls, callBack) { + if (otherDecls) { + var isAlreadyWalkingOtherDecl = TypeScript.ArrayUtilities.any(this.currentlyWalkingOtherDecls, function (inWalkingOtherDecl) { + return TypeScript.ArrayUtilities.contains(otherDecls, inWalkingOtherDecl); + }); + + if (!isAlreadyWalkingOtherDecl) { + this.currentlyWalkingOtherDecls.push(currentDecl); + for (var i = 0; i < otherDecls.length; i++) { + if (otherDecls[i] !== currentDecl) { + callBack(otherDecls[i]); + } + } + var currentlyWalkingOtherDeclsDecl = this.currentlyWalkingOtherDecls.pop(); + TypeScript.Debug.assert(currentlyWalkingOtherDeclsDecl == currentDecl); + } + } + }; + return OtherPullDeclsWalker; + })(); + PullHelpers.OtherPullDeclsWalker = OtherPullDeclsWalker; })(TypeScript.PullHelpers || (TypeScript.PullHelpers = {})); var PullHelpers = TypeScript.PullHelpers; })(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var WrapsTypeParameterCache = (function () { + function WrapsTypeParameterCache() { + this._wrapsTypeParameterCache = TypeScript.BitVector.getBitVector(true); + } + WrapsTypeParameterCache.prototype.getWrapsTypeParameter = function (typeParameterArgumentMap) { + var mapHasTypeParameterNotCached = false; + for (var typeParameterID in typeParameterArgumentMap) { + if (typeParameterArgumentMap.hasOwnProperty(typeParameterID)) { + var cachedValue = this._wrapsTypeParameterCache.valueAt(typeParameterID); + if (cachedValue) { + return typeParameterID; + } + mapHasTypeParameterNotCached = mapHasTypeParameterNotCached || cachedValue === undefined; + } + } + + if (!mapHasTypeParameterNotCached) { + return 0; + } + + return undefined; + }; + + WrapsTypeParameterCache.prototype.setWrapsTypeParameter = function (typeParameterArgumentMap, wrappingTypeParameterID) { + if (wrappingTypeParameterID) { + this._wrapsTypeParameterCache.setValueAt(wrappingTypeParameterID, true); + } else { + for (var typeParameterID in typeParameterArgumentMap) { + if (typeParameterArgumentMap.hasOwnProperty(typeParameterID)) { + this._wrapsTypeParameterCache.setValueAt(typeParameterID, false); + } + } + } + }; + return WrapsTypeParameterCache; + })(); + TypeScript.WrapsTypeParameterCache = WrapsTypeParameterCache; + + (function (PullInstantiationHelpers) { + var MutableTypeArgumentMap = (function () { + function MutableTypeArgumentMap(typeParameterArgumentMap) { + this.typeParameterArgumentMap = typeParameterArgumentMap; + this.createdDuplicateTypeArgumentMap = false; + } + MutableTypeArgumentMap.prototype.ensureTypeArgumentCopy = function () { + if (!this.createdDuplicateTypeArgumentMap) { + var passedInTypeArgumentMap = this.typeParameterArgumentMap; + this.typeParameterArgumentMap = []; + for (var typeParameterID in passedInTypeArgumentMap) { + if (passedInTypeArgumentMap.hasOwnProperty(typeParameterID)) { + this.typeParameterArgumentMap[typeParameterID] = passedInTypeArgumentMap[typeParameterID]; + } + } + this.createdDuplicateTypeArgumentMap = true; + } + }; + return MutableTypeArgumentMap; + })(); + PullInstantiationHelpers.MutableTypeArgumentMap = MutableTypeArgumentMap; + + function instantiateTypeArgument(resolver, symbol, mutableTypeParameterMap) { + if (symbol.getIsSpecialized()) { + var rootTypeArgumentMap = symbol.getTypeParameterArgumentMap(); + var newTypeArgumentMap = []; + var allowedTypeParameters = symbol.getAllowedToReferenceTypeParameters(); + for (var i = 0; i < allowedTypeParameters.length; i++) { + var typeParameterID = allowedTypeParameters[i].pullSymbolID; + var typeArg = rootTypeArgumentMap[typeParameterID]; + if (typeArg) { + newTypeArgumentMap[typeParameterID] = resolver.instantiateType(typeArg, mutableTypeParameterMap.typeParameterArgumentMap); + } + } + + for (var i = 0; i < allowedTypeParameters.length; i++) { + var typeParameterID = allowedTypeParameters[i].pullSymbolID; + if (newTypeArgumentMap[typeParameterID] && mutableTypeParameterMap.typeParameterArgumentMap[typeParameterID] != newTypeArgumentMap[typeParameterID]) { + mutableTypeParameterMap.ensureTypeArgumentCopy(); + mutableTypeParameterMap.typeParameterArgumentMap[typeParameterID] = newTypeArgumentMap[typeParameterID]; + } + } + } + } + PullInstantiationHelpers.instantiateTypeArgument = instantiateTypeArgument; + + function cleanUpTypeArgumentMap(symbol, mutableTypeArgumentMap) { + var allowedToReferenceTypeParameters = symbol.getAllowedToReferenceTypeParameters(); + for (var typeParameterID in mutableTypeArgumentMap.typeParameterArgumentMap) { + if (mutableTypeArgumentMap.typeParameterArgumentMap.hasOwnProperty(typeParameterID)) { + if (!TypeScript.ArrayUtilities.any(allowedToReferenceTypeParameters, function (typeParameter) { + return typeParameter.pullSymbolID == typeParameterID; + })) { + mutableTypeArgumentMap.ensureTypeArgumentCopy(); + delete mutableTypeArgumentMap.typeParameterArgumentMap[typeParameterID]; + } + } + } + } + PullInstantiationHelpers.cleanUpTypeArgumentMap = cleanUpTypeArgumentMap; + + function getAllowedToReferenceTypeParametersFromDecl(decl) { + var allowedToReferenceTypeParameters = []; + + var allowedToUseDeclTypeParameters = false; + var getTypeParametersFromParentDecl = false; + + switch (decl.kind) { + case 65536 /* Method */: + if (TypeScript.hasFlag(decl.flags, 16 /* Static */)) { + allowedToUseDeclTypeParameters = true; + break; + } + + case 16777216 /* FunctionType */: + case 33554432 /* ConstructorType */: + case 2097152 /* ConstructSignature */: + case 1048576 /* CallSignature */: + case 131072 /* FunctionExpression */: + case 16384 /* Function */: + allowedToUseDeclTypeParameters = true; + getTypeParametersFromParentDecl = true; + break; + + case 4096 /* Property */: + if (TypeScript.hasFlag(decl.flags, 16 /* Static */)) { + break; + } + + case 2048 /* Parameter */: + case 262144 /* GetAccessor */: + case 524288 /* SetAccessor */: + case 32768 /* ConstructorMethod */: + case 4194304 /* IndexSignature */: + case 8388608 /* ObjectType */: + case 256 /* ObjectLiteral */: + case 8192 /* TypeParameter */: + getTypeParametersFromParentDecl = true; + break; + + case 8 /* Class */: + case 16 /* Interface */: + allowedToUseDeclTypeParameters = true; + break; + } + + if (getTypeParametersFromParentDecl) { + allowedToReferenceTypeParameters = allowedToReferenceTypeParameters.concat(getAllowedToReferenceTypeParametersFromDecl(decl.getParentDecl())); + } + + if (allowedToUseDeclTypeParameters) { + var typeParameterDecls = decl.getTypeParameters(); + for (var i = 0; i < typeParameterDecls.length; i++) { + allowedToReferenceTypeParameters.push(typeParameterDecls[i].getSymbol()); + } + } + + return allowedToReferenceTypeParameters; + } + PullInstantiationHelpers.getAllowedToReferenceTypeParametersFromDecl = getAllowedToReferenceTypeParametersFromDecl; + + function createTypeParameterArgumentMap(typeParameters, typeArguments) { + return updateTypeParameterArgumentMap(typeParameters, typeArguments, {}); + } + PullInstantiationHelpers.createTypeParameterArgumentMap = createTypeParameterArgumentMap; + + function updateTypeParameterArgumentMap(typeParameters, typeArguments, typeParameterArgumentMap) { + for (var i = 0; i < typeParameters.length; i++) { + typeParameterArgumentMap[typeParameters[i].getRootSymbol().pullSymbolID] = typeArguments[i]; + } + return typeParameterArgumentMap; + } + PullInstantiationHelpers.updateTypeParameterArgumentMap = updateTypeParameterArgumentMap; + + function updateMutableTypeParameterArgumentMap(typeParameters, typeArguments, mutableMap) { + for (var i = 0; i < typeParameters.length; i++) { + var typeParameterId = typeParameters[i].getRootSymbol().pullSymbolID; + if (mutableMap.typeParameterArgumentMap[typeParameterId] !== typeArguments[i]) { + mutableMap.ensureTypeArgumentCopy(); + mutableMap.typeParameterArgumentMap[typeParameterId] = typeArguments[i]; + } + } + } + PullInstantiationHelpers.updateMutableTypeParameterArgumentMap = updateMutableTypeParameterArgumentMap; + + function twoTypesAreInstantiationsOfSameNamedGenericType(type1, type2) { + var type1IsGeneric = type1.isGeneric() && type1.getTypeArguments() !== null; + var type2IsGeneric = type2.isGeneric() && type2.getTypeArguments() !== null; + + if (type1IsGeneric && type2IsGeneric) { + var type1Root = TypeScript.PullHelpers.getRootType(type1); + var type2Root = TypeScript.PullHelpers.getRootType(type2); + return type1Root === type2Root; + } + + return false; + } + PullInstantiationHelpers.twoTypesAreInstantiationsOfSameNamedGenericType = twoTypesAreInstantiationsOfSameNamedGenericType; + })(TypeScript.PullInstantiationHelpers || (TypeScript.PullInstantiationHelpers = {})); + var PullInstantiationHelpers = TypeScript.PullInstantiationHelpers; +})(TypeScript || (TypeScript = {})); if (Error) Error.stackTraceLimit = 1000; @@ -53286,10 +54971,19 @@ var TypeScript; TypeScript.ioHostCreateDirectoryStructureTime = 0; TypeScript.ioHostWriteFileTime = 0; + (function (EmitOutputResult) { + EmitOutputResult[EmitOutputResult["Succeeded"] = 0] = "Succeeded"; + EmitOutputResult[EmitOutputResult["FailedBecauseOfSyntaxErrors"] = 1] = "FailedBecauseOfSyntaxErrors"; + EmitOutputResult[EmitOutputResult["FailedBecauseOfCompilerOptionsErrors"] = 2] = "FailedBecauseOfCompilerOptionsErrors"; + EmitOutputResult[EmitOutputResult["FailedToGenerateDeclarationsBecauseOfSemanticErrors"] = 3] = "FailedToGenerateDeclarationsBecauseOfSemanticErrors"; + })(TypeScript.EmitOutputResult || (TypeScript.EmitOutputResult = {})); + var EmitOutputResult = TypeScript.EmitOutputResult; + var EmitOutput = (function () { - function EmitOutput() { + function EmitOutput(emitOutputResult) { + if (typeof emitOutputResult === "undefined") { emitOutputResult = 0 /* Succeeded */; } this.outputFiles = []; - this.diagnostics = []; + this.emitOutputResult = emitOutputResult; } return EmitOutput; })(); @@ -53391,17 +55085,6 @@ var TypeScript; this.semanticInfoChain.removeDocument(fileName); }; - TypeScriptCompiler.prototype._isDynamicModuleCompilation = function () { - var fileNames = this.fileNames(); - for (var i = 0, n = fileNames.length; i < n; i++) { - var document = this.getDocument(fileNames[i]); - if (!document.isDeclareFile() && document.isExternalModule()) { - return true; - } - } - return false; - }; - TypeScriptCompiler.prototype.mapOutputFileName = function (document, emitOptions, extensionChanger) { if (document.emitToOwnOutputFile()) { var updatedFileName = document.fileName; @@ -53501,7 +55184,7 @@ var TypeScript; var emitOptions = new TypeScript.EmitOptions(this, resolvePath); if (emitOptions.diagnostic()) { - emitOutput.diagnostics.push(emitOptions.diagnostic()); + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; return emitOutput; } @@ -53533,7 +55216,7 @@ var TypeScript; var emitOptions = new TypeScript.EmitOptions(this, resolvePath); if (emitOptions.diagnostic()) { - emitOutput.diagnostics.push(emitOptions.diagnostic()); + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; return emitOutput; } @@ -53549,6 +55232,12 @@ var TypeScript; } }; + TypeScriptCompiler.prototype.canEmitDeclarations = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + var document = this.getDocument(fileName); + return this._shouldEmitDeclarations(document); + }; + TypeScriptCompiler.mapToFileNameExtension = function (extension, fileName, wholeFileNameReplaced) { if (wholeFileNameReplaced) { return fileName; @@ -53609,7 +55298,7 @@ var TypeScript; var emitOptions = new TypeScript.EmitOptions(this, resolvePath); if (emitOptions.diagnostic()) { - emitOutput.diagnostics.push(emitOptions.diagnostic()); + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; return emitOutput; } @@ -53640,7 +55329,7 @@ var TypeScript; var emitOptions = new TypeScript.EmitOptions(this, resolvePath); if (emitOptions.diagnostic()) { - emitOutput.diagnostics.push(emitOptions.diagnostic()); + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; return emitOutput; } @@ -53715,6 +55404,15 @@ var TypeScript; return errors; }; + TypeScriptCompiler.prototype.getCompilerOptionsDiagnostics = function () { + var emitOptions = new TypeScript.EmitOptions(this, null); + var emitDiagnostic = emitOptions.diagnostic(); + if (emitDiagnostic) { + return [emitDiagnostic]; + } + return TypeScript.sentinelEmptyArray; + }; + TypeScriptCompiler.prototype.resolveAllFiles = function () { var fileNames = this.fileNames(); for (var i = 0, n = fileNames.length; i < n; i++) { @@ -53791,8 +55489,6 @@ var TypeScript; var contextualType = null; if ((i + 2 < n) && callExpression.argumentList === path[i + 1] && callExpression.argumentList.arguments === path[i + 2]) { - var arguments = callExpression.argumentList.arguments; - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); if (isNew) { resolver.resolveObjectCreationExpression(callExpression, resolutionContext, callResolutionResults); @@ -53822,7 +55518,7 @@ var TypeScript; } } - resolutionContext.pushContextualType(contextualType, false, null); + resolutionContext.pushNewContextualType(contextualType); } break; @@ -53835,7 +55531,7 @@ var TypeScript; contextualType = currentContextualType.getElementType(); } - resolutionContext.pushContextualType(contextualType, false, null); + resolutionContext.pushNewContextualType(contextualType); } break; @@ -53862,7 +55558,7 @@ var TypeScript; } } - resolutionContext.pushContextualType(contextualType, false, null); + resolutionContext.pushNewContextualType(contextualType); } } @@ -53881,7 +55577,25 @@ var TypeScript; } } - resolutionContext.pushContextualType(contextualType, false, null); + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 220 /* CastExpression */: + var castExpression = current; + if (!(i + 1 < n && path[i + 1] === castExpression.type)) { + if (propagateContextualTypes) { + var contextualType = null; + var typeSymbol = resolver.resolveAST(castExpression, inContextuallyTypedAssignment, resolutionContext).type; + + if (typeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = typeSymbol; + } + + resolutionContext.pushNewContextualType(contextualType); + } } break; @@ -53892,7 +55606,7 @@ var TypeScript; var contextualType = null; if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */)) { - var typeAnnotation = TypeScript.getType(enclosingDeclAST); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); if (typeAnnotation) { var returnTypeSymbol = resolver.resolveTypeReference(typeAnnotation, resolutionContext); if (returnTypeSymbol) { @@ -53902,7 +55616,8 @@ var TypeScript; } else { var currentContextualType = resolutionContext.getContextualType(); if (currentContextualType && currentContextualType.isFunction()) { - var currentContextualTypeSignatureSymbol = currentContextualType.getDeclarations()[0].getSignatureSymbol(); + var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); + var currentContextualTypeSignatureSymbol = contextualSignatures[0]; var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; if (currentContextualTypeReturnTypeSymbol) { inContextuallyTypedAssignment = true; @@ -53912,7 +55627,7 @@ var TypeScript; } } - resolutionContext.pushContextualType(contextualType, false, null); + resolutionContext.pushNewContextualType(contextualType); } break; @@ -53927,6 +55642,10 @@ var TypeScript; case 163 /* WithStatement */: inWithBlock = true; break; + + case 146 /* Block */: + inContextuallyTypedAssignment = false; + break; } var decl = this.semanticInfoChain.getDeclForAST(current); @@ -53968,7 +55687,7 @@ var TypeScript; contextualType = varSymbol.type; } - resolutionContext.pushContextualType(contextualType, false, null); + resolutionContext.pushNewContextualType(contextualType); if (init) { resolver.resolveAST(init, inContextuallyTypedAssignment, resolutionContext); @@ -53999,7 +55718,7 @@ var TypeScript; var symbol = resolver.resolveAST(ast, context.inContextuallyTypedAssignment, context.resolutionContext); if (!symbol) { - TypeScript.Debug.assert(ast.kind() == 120 /* SourceUnit */, "No symbol was found for ast and ast was not source unit. Ast Kind: " + TypeScript.SyntaxKind[ast.kind()]); + TypeScript.Debug.assert(ast.kind() === 120 /* SourceUnit */, "No symbol was found for ast and ast was not source unit. Ast Kind: " + TypeScript.SyntaxKind[ast.kind()]); return null; } @@ -54140,6 +55859,32 @@ var TypeScript; TypeScriptCompiler.prototype.topLevelDecl = function (fileName) { return this.semanticInfoChain.topLevelDecl(fileName); }; + + TypeScriptCompiler.getLocationText = function (location) { + return location.fileName() + "(" + (location.line() + 1) + "," + (location.character() + 1) + ")"; + }; + + TypeScriptCompiler.getFullDiagnosticText = function (diagnostic) { + var result = ""; + if (diagnostic.fileName()) { + result += this.getLocationText(diagnostic) + ": "; + } + + result += diagnostic.message(); + + var additionalLocations = diagnostic.additionalLocations(); + if (additionalLocations.length > 0) { + result += " " + TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Additional_locations, null) + TypeScript.Environment.newLine; + + for (var i = 0, n = additionalLocations.length; i < n; i++) { + result += "\t" + this.getLocationText(additionalLocations[i]) + TypeScript.Environment.newLine; + } + } else { + result += TypeScript.Environment.newLine; + } + + return result; + }; return TypeScriptCompiler; })(); TypeScript.TypeScriptCompiler = TypeScriptCompiler; @@ -54220,11 +55965,11 @@ var TypeScript; case 0 /* Syntax */: case 1 /* Semantics */: - return this.index == this.fileNames.length; + return this.index === this.fileNames.length; case 3 /* Emit */: case 4 /* DeclarationEmit */: - return this.index == (this.fileNames.length + 1); + return this.index === (this.fileNames.length + 1); } return false; @@ -54344,10 +56089,10 @@ var TypeScript; function compareDataObjects(dst, src) { for (var e in dst) { - if (typeof dst[e] == "object") { + if (typeof dst[e] === "object") { if (!compareDataObjects(dst[e], src[e])) return false; - } else if (typeof dst[e] != "function") { + } else if (typeof dst[e] !== "function") { if (dst[e] !== src[e]) return false; } @@ -54373,7 +56118,7 @@ var TypeScript; this.referencedTypeSymbol = referencedTypeSymbol; this.isResolved = true; - TypeScript.Debug.assert(referencedTypeSymbol != null, "Type root symbol may not be null"); + TypeScript.Debug.assert(referencedTypeSymbol !== null, "Type root symbol may not be null"); this.setRootSymbol(referencedTypeSymbol); @@ -54540,11 +56285,17 @@ var TypeScript; return this.referencedTypeSymbol.getTypeArgumentsOrTypeParameters(); }; - PullTypeReferenceSymbol.prototype.addCallSignature = function (callSignature) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addCallSignature"); + PullTypeReferenceSymbol.prototype.appendCallSignature = function (callSignature) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": appendCallSignature"); }; - PullTypeReferenceSymbol.prototype.addConstructSignature = function (constructSignature) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addConstructSignature"); + PullTypeReferenceSymbol.prototype.insertCallSignatureAtIndex = function (callSignature, index) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": insertCallSignatureAtIndex"); + }; + PullTypeReferenceSymbol.prototype.appendConstructSignature = function (callSignature) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": appendConstructSignature"); + }; + PullTypeReferenceSymbol.prototype.insertConstructSignatureAtIndex = function (callSignature, index) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": insertConstructSignatureAtIndex"); }; PullTypeReferenceSymbol.prototype.addIndexSignature = function (indexSignature) { TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addIndexSignature"); @@ -54604,11 +56355,6 @@ var TypeScript; return this.referencedTypeSymbol.getTypesThatExplicitlyImplementThisType(); }; - PullTypeReferenceSymbol.prototype.hasBase = function (potentialBase, visited) { - if (typeof visited === "undefined") { visited = []; } - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasBase(potentialBase, visited); - }; PullTypeReferenceSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { this.ensureReferencedTypeIsResolved(); return this.referencedTypeSymbol.isValidBaseKind(baseType, isExtendedType); @@ -54653,25 +56399,26 @@ var TypeScript; TypeScript.nSpecializationsCreated = 0; TypeScript.nSpecializedSignaturesCreated = 0; + TypeScript.nSpecializedTypeParameterCreated = 0; var PullInstantiatedTypeReferenceSymbol = (function (_super) { __extends(PullInstantiatedTypeReferenceSymbol, _super); - function PullInstantiatedTypeReferenceSymbol(referencedTypeSymbol, _typeParameterArgumentMap) { + function PullInstantiatedTypeReferenceSymbol(referencedTypeSymbol, _typeParameterArgumentMap, isInstanceReferenceType) { _super.call(this, referencedTypeSymbol); this.referencedTypeSymbol = referencedTypeSymbol; this._typeParameterArgumentMap = _typeParameterArgumentMap; + this.isInstanceReferenceType = isInstanceReferenceType; this._instantiatedMembers = null; this._allInstantiatedMemberNameCache = null; this._instantiatedMemberNameCache = TypeScript.createIntrinsicsObject(); this._instantiatedCallSignatures = null; this._instantiatedConstructSignatures = null; this._instantiatedIndexSignatures = null; - this._typeArgumentReferences = null; + this._typeArgumentReferences = undefined; this._instantiatedConstructorMethod = null; this._instantiatedAssociatedContainerType = null; this._isArray = undefined; - this.isInstanceReferenceType = false; - this._generativeTypeClassification = 0 /* Unknown */; + this._generativeTypeClassification = []; TypeScript.nSpecializationsCreated++; } @@ -54680,72 +56427,43 @@ var TypeScript; }; PullInstantiatedTypeReferenceSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { - if (this._generativeTypeClassification == 0 /* Unknown */) { - var typeParameters = enclosingType.getTypeParameters(); - var typeReferenceTypeArguments = this.getRootSymbol().getTypeArguments(); - var referenceTypeArgument = null; - - if (!typeReferenceTypeArguments) { - var typeParametersMap = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeParametersMap[typeParameters[i].pullSymbolID] = typeParameters[i]; - } - - var rootThis = TypeScript.PullHelpers.getRootType(this); - var wrapsSomeTypeParameters = rootThis.wrapsSomeTypeParameter(typeParametersMap); - - if (wrapsSomeTypeParameters && this.wrapsSomeNestedTypeIntoInfiniteExpansion(enclosingType)) { - this._generativeTypeClassification = 3 /* InfinitelyExpanding */; - } else if (wrapsSomeTypeParameters) { - this._generativeTypeClassification = 1 /* Open */; - } else { - this._generativeTypeClassification = 2 /* Closed */; - } - } else { - var i = 0; - - while (i < typeReferenceTypeArguments.length) { - referenceTypeArgument = typeReferenceTypeArguments[i].getRootSymbol(); - - if (referenceTypeArgument.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - break; - } - - i++; - } - - if (i == typeParameters.length) { - this._generativeTypeClassification = 2 /* Closed */; - } - - if (this._generativeTypeClassification == 0 /* Unknown */) { - var i = 0; - - while ((this._generativeTypeClassification == 0 /* Unknown */) && (i < typeReferenceTypeArguments.length)) { - for (var j = 0; j < typeParameters.length; j++) { - if (typeParameters[j] == typeReferenceTypeArguments[i]) { - this._generativeTypeClassification = 1 /* Open */; - break; - } - } - - i++; - } - - if (this._generativeTypeClassification != 1 /* Open */) { - this._generativeTypeClassification = 3 /* InfinitelyExpanding */; - } - } - } + if (!this.isNamedTypeSymbol()) { + return 0 /* Unknown */; } - return this._generativeTypeClassification; + var generativeTypeClassification = this._generativeTypeClassification[enclosingType.pullSymbolID] || 0 /* Unknown */; + if (generativeTypeClassification === 0 /* Unknown */) { + var typeParameters = enclosingType.getTypeParameters(); + var enclosingTypeParameterMap = []; + for (var i = 0; i < typeParameters.length; i++) { + enclosingTypeParameterMap[typeParameters[i].pullSymbolID] = typeParameters[i]; + } + + var typeArguments = this.getTypeArguments(); + for (var i = 0; i < typeArguments.length; i++) { + if (typeArguments[i].wrapsSomeTypeParameter(enclosingTypeParameterMap, true)) { + generativeTypeClassification = 1 /* Open */; + break; + } + } + + if (generativeTypeClassification === 1 /* Open */) { + if (this.wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference(enclosingType)) { + generativeTypeClassification = 3 /* InfinitelyExpanding */; + } + } else { + generativeTypeClassification = 2 /* Closed */; + } + + this._generativeTypeClassification[enclosingType.pullSymbolID] = generativeTypeClassification; + } + + return generativeTypeClassification; }; PullInstantiatedTypeReferenceSymbol.prototype.isArrayNamedTypeReference = function () { if (this._isArray === undefined) { - this._isArray = this.getRootSymbol().isArrayNamedTypeReference() || (this.getRootSymbol() == this._getResolver().getArrayNamedType()); + this._isArray = this.getRootSymbol().isArrayNamedTypeReference() || (this.getRootSymbol() === this._getResolver().getArrayNamedType()); } return this._isArray; }; @@ -54756,12 +56474,7 @@ var TypeScript; } var typeArguments = this.getTypeArguments(); - - if (typeArguments != null) { - return typeArguments[0]; - } - - return null; + return typeArguments ? typeArguments[0] : null; }; PullInstantiatedTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { @@ -54774,130 +56487,47 @@ var TypeScript; return this.referencedTypeSymbol; }; - PullInstantiatedTypeReferenceSymbol.create = function (resolver, type, typeParameterArgumentMap, instantiateFunctionTypeParameters) { - if (typeof instantiateFunctionTypeParameters === "undefined") { instantiateFunctionTypeParameters = false; } + PullInstantiatedTypeReferenceSymbol.create = function (resolver, type, typeParameterArgumentMap) { TypeScript.Debug.assert(resolver); + var mutableTypeParameterMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(typeParameterArgumentMap); + + TypeScript.PullInstantiationHelpers.instantiateTypeArgument(resolver, type, mutableTypeParameterMap); + var rootType = type.getRootSymbol(); - - var reconstructedTypeArgumentList = []; - var typeArguments = type.getTypeArguments(); - var typeParameters = rootType.getTypeParameters(); - - if (type.getIsSpecialized() && typeArguments && typeArguments.length) { - for (var i = 0; i < typeArguments.length; i++) { - reconstructedTypeArgumentList[reconstructedTypeArgumentList.length] = resolver.instantiateType(typeArguments[i], typeParameterArgumentMap, instantiateFunctionTypeParameters); - } - - for (var i = 0; i < typeArguments.length; i++) { - typeParameterArgumentMap[typeArguments[i].pullSymbolID] = reconstructedTypeArgumentList[i]; - } - } else { - var tyArg = null; - - for (var typeParameterID in typeParameterArgumentMap) { - if (typeParameterArgumentMap.hasOwnProperty(typeParameterID)) { - tyArg = typeParameterArgumentMap[typeParameterID]; - - if (tyArg) { - reconstructedTypeArgumentList[reconstructedTypeArgumentList.length] = tyArg; - } - } - } + var instantiation = rootType.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); + if (instantiation) { + return instantiation; } - if (!instantiateFunctionTypeParameters) { - var instantiation = rootType.getSpecialization(reconstructedTypeArgumentList); + TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(type, mutableTypeParameterMap); + typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; - if (instantiation) { - return instantiation; - } - } - - var isReferencedType = (type.kind & 8216 /* SomeInstantiatableType */) != 0; - - if (isReferencedType) { - if (typeParameters && reconstructedTypeArgumentList) { - if (typeParameters.length == reconstructedTypeArgumentList.length) { - for (var i = 0; i < typeParameters.length; i++) { - if (!TypeScript.PullHelpers.typeSymbolsAreIdentical(typeParameters[i], reconstructedTypeArgumentList[i])) { - isReferencedType = false; - break; - } - } - - if (isReferencedType) { - typeParameterArgumentMap = []; - } - } else { - isReferencedType = false; - } - } - } - - var instantiateRoot = isReferencedType; - - if (type.isTypeReference() && type.isGeneric()) { - var initializationMap = []; - - for (var typeParameterID in typeParameterArgumentMap) { - if (typeParameterArgumentMap.hasOwnProperty(typeParameterID)) { - initializationMap[typeParameterID] = typeParameterArgumentMap[typeParameterID]; + var isInstanceReferenceType = (type.kind & 8216 /* SomeInstantiatableType */) != 0; + var resolvedTypeParameterArgumentMap = typeParameterArgumentMap; + if (isInstanceReferenceType) { + var typeParameters = rootType.getTypeParameters(); + for (var i = 0; i < typeParameters.length; i++) { + if (!TypeScript.PullHelpers.typeSymbolsAreIdentical(typeParameters[i], typeParameterArgumentMap[typeParameters[i].pullSymbolID])) { + isInstanceReferenceType = false; + break; } } - var oldMap = typeParameterArgumentMap; - - var outerTypeMap = type._typeParameterArgumentMap; - var innerSubstitution = null; - var outerSubstitution = null; - var canRelatePreInstantiatedTypeParametersToRootTypeParameters = true; - - for (var typeParameterID in outerTypeMap) { - if (outerTypeMap.hasOwnProperty(typeParameterID)) { - outerSubstitution = outerTypeMap[typeParameterID]; - innerSubstitution = typeParameterArgumentMap[outerSubstitution.pullSymbolID]; - - if (innerSubstitution && (!outerSubstitution.isTypeParameter() || !outerTypeMap[innerSubstitution.pullSymbolID] || !outerTypeMap[outerTypeMap[typeParameterID].pullSymbolID] || (outerTypeMap[outerTypeMap[typeParameterID].pullSymbolID] == outerSubstitution))) { - initializationMap[typeParameterID] = typeParameterArgumentMap[outerTypeMap[typeParameterID].pullSymbolID]; - - if (!outerSubstitution.isTypeParameter()) { - canRelatePreInstantiatedTypeParametersToRootTypeParameters = false; - } - } else { - canRelatePreInstantiatedTypeParametersToRootTypeParameters = false; - } - } - } - - if (canRelatePreInstantiatedTypeParametersToRootTypeParameters && typeParameters.length) { + if (isInstanceReferenceType) { typeParameterArgumentMap = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameterArgumentMap[typeParameters[i].pullSymbolID] = initializationMap[typeParameters[i].pullSymbolID]; - } - - instantiateRoot = true; - } else { - typeParameterArgumentMap = initializationMap; } } - instantiation = new PullInstantiatedTypeReferenceSymbol(instantiateRoot ? rootType : type, typeParameterArgumentMap); + instantiation = new PullInstantiatedTypeReferenceSymbol(rootType, typeParameterArgumentMap, isInstanceReferenceType); - if (!instantiateFunctionTypeParameters) { - rootType.addSpecialization(instantiation, reconstructedTypeArgumentList); - } - - if (isReferencedType) { - instantiation.isInstanceReferenceType = true; - } + rootType.addSpecialization(instantiation, resolvedTypeParameterArgumentMap); return instantiation; }; PullInstantiatedTypeReferenceSymbol.prototype.isGeneric = function () { - return !!this.referencedTypeSymbol.getTypeParameters().length; + return this.getRootSymbol().isGeneric(); }; PullInstantiatedTypeReferenceSymbol.prototype.getTypeParameterArgumentMap = function () { @@ -54909,7 +56539,7 @@ var TypeScript; return this.getTypeParameters(); } - if (!this._typeArgumentReferences) { + if (this._typeArgumentReferences === undefined) { var typeParameters = this.referencedTypeSymbol.getTypeParameters(); if (typeParameters.length) { @@ -54929,6 +56559,8 @@ var TypeScript; } this._typeArgumentReferences = typeArguments; + } else { + this._typeArgumentReferences = null; } } @@ -54939,6 +56571,21 @@ var TypeScript; return this.getTypeArguments(); }; + PullInstantiatedTypeReferenceSymbol.prototype.populateInstantiatedMemberFromReferencedMember = function (referencedMember) { + var instantiatedMember; + TypeScript.PullHelpers.resolveDeclaredSymbolToUseType(referencedMember); + + if (!referencedMember.type.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + instantiatedMember = referencedMember; + } else { + instantiatedMember = new TypeScript.PullSymbol(referencedMember.name, referencedMember.kind); + instantiatedMember.setRootSymbol(referencedMember); + instantiatedMember.type = this._getResolver().instantiateType(referencedMember.type, this._typeParameterArgumentMap); + instantiatedMember.isOptional = referencedMember.isOptional; + } + this._instantiatedMemberNameCache[instantiatedMember.name] = instantiatedMember; + }; + PullInstantiatedTypeReferenceSymbol.prototype.getMembers = function () { this.ensureReferencedTypeIsResolved(); @@ -54959,21 +56606,10 @@ var TypeScript; this._getResolver().resolveDeclaredSymbol(referencedMember); if (!this._instantiatedMemberNameCache[referencedMember.name]) { - if (!referencedMember.type.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - instantiatedMember = referencedMember; - } else { - instantiatedMember = new TypeScript.PullSymbol(referencedMember.name, referencedMember.kind); - instantiatedMember.setRootSymbol(referencedMember); - instantiatedMember.type = this._getResolver().instantiateType(referencedMember.type, this._typeParameterArgumentMap); - instantiatedMember.isOptional = referencedMember.isOptional; - } - - this._instantiatedMemberNameCache[instantiatedMember.name] = instantiatedMember; - } else { - instantiatedMember = this._instantiatedMemberNameCache[referencedMember.name]; + this.populateInstantiatedMemberFromReferencedMember(referencedMember); } - this._instantiatedMembers[this._instantiatedMembers.length] = instantiatedMember; + this._instantiatedMembers[this._instantiatedMembers.length] = this._instantiatedMemberNameCache[referencedMember.name]; } } @@ -54994,16 +56630,8 @@ var TypeScript; var referencedMemberSymbol = this.referencedTypeSymbol.findMember(name, lookInParent); if (referencedMemberSymbol) { - memberSymbol = new TypeScript.PullSymbol(referencedMemberSymbol.name, referencedMemberSymbol.kind); - memberSymbol.setRootSymbol(referencedMemberSymbol); - - this._getResolver().resolveDeclaredSymbol(referencedMemberSymbol); - - memberSymbol.type = this._getResolver().instantiateType(referencedMemberSymbol.type, this._typeParameterArgumentMap); - - memberSymbol.isOptional = referencedMemberSymbol.isOptional; - - this._instantiatedMemberNameCache[memberSymbol.name] = memberSymbol; + this.populateInstantiatedMemberFromReferencedMember(referencedMemberSymbol); + memberSymbol = this._instantiatedMemberNameCache[name]; } else { memberSymbol = null; } @@ -55070,6 +56698,9 @@ var TypeScript; if (!this._instantiatedConstructorMethod) { var referencedConstructorMethod = this.referencedTypeSymbol.getConstructorMethod(); this._instantiatedConstructorMethod = new TypeScript.PullSymbol(referencedConstructorMethod.name, referencedConstructorMethod.kind); + this._instantiatedConstructorMethod.setRootSymbol(referencedConstructorMethod); + this._instantiatedConstructorMethod.setResolved(); + this._instantiatedConstructorMethod.type = PullInstantiatedTypeReferenceSymbol.create(this._getResolver(), referencedConstructorMethod.type, this._typeParameterArgumentMap); } @@ -55175,14 +56806,79 @@ var TypeScript; return this._instantiatedIndexSignatures; }; - - PullInstantiatedTypeReferenceSymbol.prototype.hasBase = function (potentialBase, visited) { - if (typeof visited === "undefined") { visited = []; } - return this.referencedTypeSymbol.hasBase(potentialBase, visited); - }; return PullInstantiatedTypeReferenceSymbol; })(PullTypeReferenceSymbol); TypeScript.PullInstantiatedTypeReferenceSymbol = PullInstantiatedTypeReferenceSymbol; + + var PullInstantiatedSignatureSymbol = (function (_super) { + __extends(PullInstantiatedSignatureSymbol, _super); + function PullInstantiatedSignatureSymbol(rootSignature, _typeParameterArgumentMap) { + _super.call(this, rootSignature.kind, rootSignature.isDefinition()); + this._typeParameterArgumentMap = _typeParameterArgumentMap; + this.setRootSymbol(rootSignature); + TypeScript.nSpecializedSignaturesCreated++; + + rootSignature.addSpecialization(this, _typeParameterArgumentMap); + } + PullInstantiatedSignatureSymbol.prototype.getTypeParameterArgumentMap = function () { + return this._typeParameterArgumentMap; + }; + + PullInstantiatedSignatureSymbol.prototype.getIsSpecialized = function () { + return true; + }; + + PullInstantiatedSignatureSymbol.prototype._getResolver = function () { + return this.getRootSymbol()._getResolver(); + }; + + PullInstantiatedSignatureSymbol.prototype.getTypeParameters = function () { + var _this = this; + if (!this._typeParameters) { + var rootSymbol = this.getRootSymbol(); + var typeParameters = rootSymbol.getTypeParameters(); + var hasInstantiatedTypeParametersOfThisSignature = TypeScript.ArrayUtilities.all(typeParameters, function (typeParameter) { + return _this._typeParameterArgumentMap[typeParameter.pullSymbolID] !== undefined; + }); + + if (!hasInstantiatedTypeParametersOfThisSignature && typeParameters.length) { + this._typeParameters = []; + for (var i = 0; i < typeParameters.length; i++) { + this._typeParameters[this._typeParameters.length] = this._getResolver().instantiateTypeParameter(typeParameters[i], this._typeParameterArgumentMap); + } + } else { + this._typeParameters = TypeScript.sentinelEmptyArray; + } + } + + return this._typeParameters; + }; + + PullInstantiatedSignatureSymbol.prototype.getAllowedToReferenceTypeParameters = function () { + var rootSymbol = this.getRootSymbol(); + return rootSymbol.getAllowedToReferenceTypeParameters(); + }; + return PullInstantiatedSignatureSymbol; + })(TypeScript.PullSignatureSymbol); + TypeScript.PullInstantiatedSignatureSymbol = PullInstantiatedSignatureSymbol; + + var PullInstantiatedTypeParameterSymbol = (function (_super) { + __extends(PullInstantiatedTypeParameterSymbol, _super); + function PullInstantiatedTypeParameterSymbol(rootTypeParameter, constraintType) { + _super.call(this, rootTypeParameter.name); + TypeScript.nSpecializedTypeParameterCreated++; + + this.setRootSymbol(rootTypeParameter); + this.setConstraint(constraintType); + + rootTypeParameter.addSpecialization(this, [constraintType]); + } + PullInstantiatedTypeParameterSymbol.prototype._getResolver = function () { + return this.getRootSymbol()._getResolver(); + }; + return PullInstantiatedTypeParameterSymbol; + })(TypeScript.PullTypeParameterSymbol); + TypeScript.PullInstantiatedTypeParameterSymbol = PullInstantiatedTypeParameterSymbol; })(TypeScript || (TypeScript = {})); var TypeScript; (function (TypeScript) { @@ -55421,8 +57117,8 @@ var TypeScript; TypeScript.Debug.assert(start === 0); var bod = this.visitSyntaxList(node.moduleElements); - - var result = new TypeScript.SourceUnit(bod, this.fileName); + var comments = this.convertTokenLeadingComments(node.endOfFileToken, TypeScript.Syntax.childOffset(node, node.endOfFileToken)); + var result = new TypeScript.SourceUnit(bod, comments, this.fileName); this.setSpanExplicit(result, start, start + node.fullWidth()); return result; @@ -55999,17 +57695,17 @@ var TypeScript; this.movePast(node.openParenToken); - var arguments = this.visitSeparatedSyntaxList(node.arguments); + var _arguments = this.visitSeparatedSyntaxList(node.arguments); if (node.arguments.fullWidth() === 0 && node.closeParenToken.fullWidth() === 0) { var openParenTokenEnd = start + node.openParenToken.leadingTriviaWidth() + node.openParenToken.width(); - this.setSpanExplicit(arguments, openParenTokenEnd, openParenTokenEnd + node.openParenToken.trailingTriviaWidth()); + this.setSpanExplicit(_arguments, openParenTokenEnd, openParenTokenEnd + node.openParenToken.trailingTriviaWidth()); } var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); this.movePast(node.closeParenToken); - var result = new TypeScript.ArgumentList(typeArguments, arguments, closeParenToken); + var result = new TypeScript.ArgumentList(typeArguments, _arguments, closeParenToken); this.setSpan(result, start, node); return result; @@ -56230,14 +57926,14 @@ var TypeScript; SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { var start = this.position; - this.moveTo(node, node.parameterList); - var parameters = this.visitParameterList(node.parameterList); + this.moveTo(node, node.callSignature); + var callSignature = this.visitCallSignature(node.callSignature); var block = node.block ? node.block.accept(this) : null; this.movePast(node.semicolonToken); - var result = new TypeScript.ConstructorDeclaration(parameters, block); + var result = new TypeScript.ConstructorDeclaration(callSignature, block); this.setCommentsAndSpan(result, start, node); return result; @@ -57648,6 +59344,10 @@ var TypeScript; return commentArrayStructuralEquals(this.preComments(), ast.preComments(), includingPosition) && commentArrayStructuralEquals(this.postComments(), ast.postComments(), includingPosition); }; + + AST.prototype.isExpression = function () { + return false; + }; return AST; })(); TypeScript.AST = AST; @@ -57749,9 +59449,10 @@ var TypeScript; var SourceUnit = (function (_super) { __extends(SourceUnit, _super); - function SourceUnit(moduleElements, _fileName) { + function SourceUnit(moduleElements, endOfFileTokenLeadingComments, _fileName) { _super.call(this); this.moduleElements = moduleElements; + this.endOfFileTokenLeadingComments = endOfFileTokenLeadingComments; this._fileName = _fileName; moduleElements && (moduleElements.parent = this); } @@ -57800,6 +59501,10 @@ var TypeScript; Identifier.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._text === ast._text; }; + + Identifier.prototype.isExpression = function () { + return true; + }; return Identifier; })(AST); TypeScript.Identifier = Identifier; @@ -57827,6 +59532,10 @@ var TypeScript; LiteralExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition); }; + + LiteralExpression.prototype.isExpression = function () { + return true; + }; return LiteralExpression; })(AST); TypeScript.LiteralExpression = LiteralExpression; @@ -57853,6 +59562,10 @@ var TypeScript; ThisExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition); }; + + ThisExpression.prototype.isExpression = function () { + return true; + }; return ThisExpression; })(AST); TypeScript.ThisExpression = ThisExpression; @@ -57879,6 +59592,10 @@ var TypeScript; SuperExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition); }; + + SuperExpression.prototype.isExpression = function () { + return true; + }; return SuperExpression; })(AST); TypeScript.SuperExpression = SuperExpression; @@ -57908,6 +59625,10 @@ var TypeScript; NumericLiteral.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && (this._value === ast._value || (isNaN(this._value) && isNaN(ast._value))) && this._text === ast._text; }; + + NumericLiteral.prototype.isExpression = function () { + return true; + }; return NumericLiteral; })(AST); TypeScript.NumericLiteral = NumericLiteral; @@ -57930,6 +59651,10 @@ var TypeScript; RegularExpressionLiteral.prototype.kind = function () { return 12 /* RegularExpressionLiteral */; }; + + RegularExpressionLiteral.prototype.isExpression = function () { + return true; + }; return RegularExpressionLiteral; })(AST); TypeScript.RegularExpressionLiteral = RegularExpressionLiteral; @@ -57956,6 +59681,10 @@ var TypeScript; StringLiteral.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._text === ast._text; }; + + StringLiteral.prototype.isExpression = function () { + return true; + }; return StringLiteral; })(AST); TypeScript.StringLiteral = StringLiteral; @@ -58279,6 +60008,10 @@ var TypeScript; PrefixUnaryExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.operand, ast.operand, includingPosition); }; + + PrefixUnaryExpression.prototype.isExpression = function () { + return true; + }; return PrefixUnaryExpression; })(AST); TypeScript.PrefixUnaryExpression = PrefixUnaryExpression; @@ -58297,6 +60030,10 @@ var TypeScript; ArrayLiteralExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expressions, ast.expressions, includingPosition); }; + + ArrayLiteralExpression.prototype.isExpression = function () { + return true; + }; return ArrayLiteralExpression; })(AST); TypeScript.ArrayLiteralExpression = ArrayLiteralExpression; @@ -58313,6 +60050,10 @@ var TypeScript; OmittedExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition); }; + + OmittedExpression.prototype.isExpression = function () { + return true; + }; return OmittedExpression; })(AST); TypeScript.OmittedExpression = OmittedExpression; @@ -58332,6 +60073,10 @@ var TypeScript; ParenthesizedExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); }; + + ParenthesizedExpression.prototype.isExpression = function () { + return true; + }; return ParenthesizedExpression; })(AST); TypeScript.ParenthesizedExpression = ParenthesizedExpression; @@ -58350,6 +60095,10 @@ var TypeScript; SimpleArrowFunctionExpression.prototype.kind = function () { return 219 /* SimpleArrowFunctionExpression */; }; + + SimpleArrowFunctionExpression.prototype.isExpression = function () { + return true; + }; return SimpleArrowFunctionExpression; })(AST); TypeScript.SimpleArrowFunctionExpression = SimpleArrowFunctionExpression; @@ -58368,6 +60117,10 @@ var TypeScript; ParenthesizedArrowFunctionExpression.prototype.kind = function () { return 218 /* ParenthesizedArrowFunctionExpression */; }; + + ParenthesizedArrowFunctionExpression.prototype.isExpression = function () { + return true; + }; return ParenthesizedArrowFunctionExpression; })(AST); TypeScript.ParenthesizedArrowFunctionExpression = ParenthesizedArrowFunctionExpression; @@ -58588,6 +60341,10 @@ var TypeScript; MemberAccessExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.name, ast.name, includingPosition); }; + + MemberAccessExpression.prototype.isExpression = function () { + return true; + }; return MemberAccessExpression; })(AST); TypeScript.MemberAccessExpression = MemberAccessExpression; @@ -58607,6 +60364,10 @@ var TypeScript; PostfixUnaryExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.operand, ast.operand, includingPosition); }; + + PostfixUnaryExpression.prototype.isExpression = function () { + return true; + }; return PostfixUnaryExpression; })(AST); TypeScript.PostfixUnaryExpression = PostfixUnaryExpression; @@ -58627,6 +60388,10 @@ var TypeScript; ElementAccessExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.argumentExpression, ast.argumentExpression, includingPosition); }; + + ElementAccessExpression.prototype.isExpression = function () { + return true; + }; return ElementAccessExpression; })(AST); TypeScript.ElementAccessExpression = ElementAccessExpression; @@ -58647,19 +60412,24 @@ var TypeScript; InvocationExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.argumentList, ast.argumentList, includingPosition); }; + + InvocationExpression.prototype.isExpression = function () { + return true; + }; return InvocationExpression; })(AST); TypeScript.InvocationExpression = InvocationExpression; var ArgumentList = (function (_super) { __extends(ArgumentList, _super); - function ArgumentList(typeArgumentList, arguments, closeParenToken) { + function ArgumentList(typeArgumentList, _arguments, closeParenToken) { _super.call(this); this.typeArgumentList = typeArgumentList; - this.arguments = arguments; this.closeParenToken = closeParenToken; + this.arguments = _arguments; + typeArgumentList && (typeArgumentList.parent = this); - arguments && (arguments.parent = this); + _arguments && (_arguments.parent = this); } ArgumentList.prototype.kind = function () { return 226 /* ArgumentList */; @@ -58685,6 +60455,10 @@ var TypeScript; BinaryExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.left, ast.left, includingPosition) && structuralEquals(this.right, ast.right, includingPosition); }; + + BinaryExpression.prototype.isExpression = function () { + return true; + }; return BinaryExpression; })(AST); TypeScript.BinaryExpression = BinaryExpression; @@ -58707,6 +60481,10 @@ var TypeScript; ConditionalExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.whenTrue, ast.whenTrue, includingPosition) && structuralEquals(this.whenFalse, ast.whenFalse, includingPosition); }; + + ConditionalExpression.prototype.isExpression = function () { + return true; + }; return ConditionalExpression; })(AST); TypeScript.ConditionalExpression = ConditionalExpression; @@ -58887,11 +60665,11 @@ var TypeScript; var ConstructorDeclaration = (function (_super) { __extends(ConstructorDeclaration, _super); - function ConstructorDeclaration(parameterList, block) { + function ConstructorDeclaration(callSignature, block) { _super.call(this); - this.parameterList = parameterList; + this.callSignature = callSignature; this.block = block; - parameterList && (parameterList.parent = this); + callSignature && (callSignature.parent = this); block && (block.parent = this); } ConstructorDeclaration.prototype.kind = function () { @@ -59041,6 +60819,10 @@ var TypeScript; ObjectCreationExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.argumentList, ast.argumentList, includingPosition); }; + + ObjectCreationExpression.prototype.isExpression = function () { + return true; + }; return ObjectCreationExpression; })(AST); TypeScript.ObjectCreationExpression = ObjectCreationExpression; @@ -59277,6 +61059,10 @@ var TypeScript; CastExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.type, ast.type, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); }; + + CastExpression.prototype.isExpression = function () { + return true; + }; return CastExpression; })(AST); TypeScript.CastExpression = CastExpression; @@ -59295,6 +61081,10 @@ var TypeScript; ObjectLiteralExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.propertyAssignments, ast.propertyAssignments, includingPosition); }; + + ObjectLiteralExpression.prototype.isExpression = function () { + return true; + }; return ObjectLiteralExpression; })(AST); TypeScript.ObjectLiteralExpression = ObjectLiteralExpression; @@ -59347,6 +61137,10 @@ var TypeScript; FunctionExpression.prototype.kind = function () { return 222 /* FunctionExpression */; }; + + FunctionExpression.prototype.isExpression = function () { + return true; + }; return FunctionExpression; })(AST); TypeScript.FunctionExpression = FunctionExpression; @@ -59484,6 +61278,10 @@ var TypeScript; TypeOfExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); }; + + TypeOfExpression.prototype.isExpression = function () { + return true; + }; return TypeOfExpression; })(AST); TypeScript.TypeOfExpression = TypeOfExpression; @@ -59502,6 +61300,10 @@ var TypeScript; DeleteExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); }; + + DeleteExpression.prototype.isExpression = function () { + return true; + }; return DeleteExpression; })(AST); TypeScript.DeleteExpression = DeleteExpression; @@ -59520,6 +61322,10 @@ var TypeScript; VoidExpression.prototype.structuralEquals = function (ast, includingPosition) { return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); }; + + VoidExpression.prototype.isExpression = function () { + return true; + }; return VoidExpression; })(AST); TypeScript.VoidExpression = VoidExpression; @@ -59571,15 +61377,4 @@ var TypeScript; return Comment; })(); TypeScript.Comment = Comment; - - function diagnosticFromDecl(decl, diagnosticKey, arguments) { - if (typeof arguments === "undefined") { arguments = null; } - var span = decl.getSpan(); - return new TypeScript.Diagnostic(decl.fileName(), decl.semanticInfoChain().lineMap(decl.fileName()), span.start(), span.length(), diagnosticKey, arguments); - } - TypeScript.diagnosticFromDecl = diagnosticFromDecl; - - function min(a, b) { - return a <= b ? a : b; - } })(TypeScript || (TypeScript = {})); diff --git a/angular-translate/angular-translate-tests.ts b/angular-translate/angular-translate-tests.ts index 7cb6c89c3..bea7faa09 100644 --- a/angular-translate/angular-translate-tests.ts +++ b/angular-translate/angular-translate-tests.ts @@ -18,7 +18,11 @@ app.config(($translateProvider: ng.translate.ITranslateProvider) => { $translateProvider.preferredLanguage('en'); }); -app.controller('Ctrl', ($scope: ng.IScope, $translate: ng.translate.ITranslateService) => { +interface Scope extends ng.IScope { + changeLanguage(key: any): void; +} + +app.controller('Ctrl', ($scope: Scope, $translate: ng.translate.ITranslateService) => { $scope['changeLanguage'] = function (key: any) { $translate.uses(key); }; diff --git a/angularfire/angularfire-tests.ts b/angularfire/angularfire-tests.ts index e3a04712c..eced9d7fe 100644 --- a/angularfire/angularfire-tests.ts +++ b/angularfire/angularfire-tests.ts @@ -25,7 +25,7 @@ myapp.controller("MyController", ["$scope", "$firebase", $scope.items.$set({ bar: "baz" }); var keys = $scope.items.$getIndex(); keys.forEach(function(key, i) { - console.log(i, $scope.items[key]); + console.log(i, ($scope.items)[key]); }); $scope.items.$on("loaded", function() { console.log("Initial data received!"); diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index c26bc9fe8..0317e17b7 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -19,19 +19,18 @@ declare module ng.resource { // that deeply. /////////////////////////////////////////////////////////////////////////// interface IResourceService { - - , U extends IResourceClass>(url: string, paramDefaults?: any, - /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } - where deleteDescriptor : IActionDescriptor */ - actionDescriptors?: any): U; - >(url: string, paramDefaults?: any, - /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } - where deleteDescriptor : IActionDescriptor */ - actionDescriptors?: any): IResourceClass; (url: string, paramDefaults?: any, /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } where deleteDescriptor : IActionDescriptor */ actionDescriptors?: any): IResourceClass>; + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actionDescriptors?: any): U; + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actionDescriptors?: any): IResourceClass; } // Just a reference to facilitate describing new actions @@ -51,7 +50,7 @@ declare module ng.resource { // PATCH (in other words, methods with body). Otherwise, it's going // to be considered as parameters to the request. // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L461-L465 - interface IResourceClass> { + interface IResourceClass { get(): T; get(dataOrParams: any): T; get(dataOrParams: any, success: Function): T; @@ -79,7 +78,7 @@ declare module ng.resource { delete(params: any, data: any, success?: Function, error?: Function): T; } - interface IResource> { + interface IResource { $get(): T; $get(dataOrParams: any): T; $get(dataOrParams: any, success: Function): T; @@ -112,7 +111,7 @@ declare module ng.resource { } /** when creating a resource factory via IModule.factory */ - interface IResourceServiceFactoryFunction> { + interface IResourceServiceFactoryFunction { ($resource: ng.resource.IResourceService): IResourceClass; >($resource: ng.resource.IResourceService): U; } @@ -127,7 +126,7 @@ declare module ng { } } -interface Array> +interface Array { /** the promise of the original server interaction that created this collection. **/ $promise : ng.IPromise>; diff --git a/cryptojs/cryptojs.d.ts b/cryptojs/cryptojs.d.ts index a12ef69e7..d9c77dbe9 100644 --- a/cryptojs/cryptojs.d.ts +++ b/cryptojs/cryptojs.d.ts @@ -106,6 +106,8 @@ declare module CryptoJS{ interface Cipher extends ICipher{} interface IStreamCipher extends ICipher{ + drop?: number; + createEncryptor(key: WordArray, cfg?: C): IStreamCipher createDecryptor(key: WordArray, cfg?: C): IStreamCipher @@ -338,10 +340,7 @@ declare module CryptoJS{ interface PBKDF2 extends EvpKDF{} //PBKDF2 is same as EvpKDF - interface RC4Drop extends RC4, lib.ICipher{} - interface IRC4DropCfg{ - drop?: number //default 192 - } + interface RC4Drop extends RC4 { } } module mode{ @@ -438,7 +437,7 @@ declare module CryptoJS{ RabbitLegacy: CryptoJS.lib.CipherHelper Rabbit: CryptoJS.lib.CipherHelper RC4: CryptoJS.lib.CipherHelper - RC4Drop: CryptoJS.lib.ICipherHelper + RC4Drop: CryptoJS.lib.ICipherHelper MD5: CryptoJS.lib.HasherHelper HmacMD5: CryptoJS.lib.IHasherHmacHelper diff --git a/ember/ember.d.ts b/ember/ember.d.ts index 9bde2eca6..80be5d04d 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -57,7 +57,7 @@ interface String { w(): string[]; } -interface Array { +interface Array { constructor(arr: any[]); activate(): void; addArrayObserver(target: any, opts?: EnumerableConfigurationOptions): any[]; diff --git a/gamepad/gamepad-tests.ts b/gamepad/gamepad-tests.ts index e6ca9d272..5d82c33ec 100644 --- a/gamepad/gamepad-tests.ts +++ b/gamepad/gamepad-tests.ts @@ -38,7 +38,7 @@ console.log('Gamepad ' + e.gamepad.index + ' disconnected!'); }, false); - var requestAnimationFrame = window.requestAnimationFrame || window["mozRequestAnimationFrame"]; + var requestAnimationFrame = window.requestAnimationFrame || (window).mozRequestAnimationFrame; var getGamepads = navigator.getGamepads || navigator.webkitGetGamepads; if(getGamepads){ function runAnimation() diff --git a/knockout.deferred.updates/knockout.deferred.updates.d.ts b/knockout.deferred.updates/knockout.deferred.updates.d.ts index 1d9313dce..e3423f5e9 100644 --- a/knockout.deferred.updates/knockout.deferred.updates.d.ts +++ b/knockout.deferred.updates/knockout.deferred.updates.d.ts @@ -21,7 +21,7 @@ interface KnockoutStatic { } // Observables -interface KnockoutSubscribableFunctions { +interface KnockoutSubscribableFunctions { deferUpdates: boolean; } diff --git a/knockout.kogrid/knockout.kogrid-tests.ts b/knockout.kogrid/knockout.kogrid-tests.ts index 94c061156..54dde59e1 100644 --- a/knockout.kogrid/knockout.kogrid-tests.ts +++ b/knockout.kogrid/knockout.kogrid-tests.ts @@ -19,7 +19,7 @@ module KoGridTests } public createDefaultGridOptions(dataArray: KnockoutObservableArray, selectedItems: KnockoutObservableArray): kg.GridOptions { - var result = { + return { data: dataArray, displaySelectionCheckbox: false, footerVisible: false, @@ -28,7 +28,6 @@ module KoGridTests plugins: null, selectedItems: selectedItems }; - return result; } } } \ No newline at end of file diff --git a/knockout.postbox/knockout-postbox.d.ts b/knockout.postbox/knockout-postbox.d.ts index daa35458a..65f0bbf13 100644 --- a/knockout.postbox/knockout-postbox.d.ts +++ b/knockout.postbox/knockout-postbox.d.ts @@ -20,11 +20,11 @@ interface KnockoutObservable { } interface KnockoutObservableArray { - subscribeTo(topic: string, useLastPublishedValueToInitialize?: boolean, transform?: (val: any) => T): KnockoutObservableArray; + subscribeTo(topic: string, useLastPublishedValueToInitialize?: boolean, transform?: (val: any) => any /* T */): KnockoutObservableArray; unsubscribeFrom(topic: string): KnockoutObservableArray; - publishOn(topic: string, skipInitialPublish?: boolean, equalityComparer?: (newValue: T, oldValue: T) => boolean): KnockoutObservableArray; + publishOn(topic: string, skipInitialPublish?: boolean, equalityComparer?: (newValue: any /* T */, oldValue: any /* T */) => boolean): KnockoutObservableArray; stopPublishingOn(topic: string): KnockoutObservableArray; - syncWith(topic: string, initializeWithLatestValue?: boolean, skipInitialPublish?: boolean, equalityComparer?: (newValue: T, oldValue: T) => boolean): KnockoutObservableArray; + syncWith(topic: string, initializeWithLatestValue?: boolean, skipInitialPublish?: boolean, equalityComparer?: (newValue: any /* T */, oldValue: any /* T */) => boolean): KnockoutObservableArray; } interface KnockoutStatic { diff --git a/knockout.validation/knockout.validation.d.ts b/knockout.validation/knockout.validation.d.ts index 2e00c5223..e65ec6743 100644 --- a/knockout.validation/knockout.validation.d.ts +++ b/knockout.validation/knockout.validation.d.ts @@ -138,7 +138,7 @@ interface KnockoutStatic { applyBindingsWithValidation(viewModel: any, rootNode?: any, options?: KnockoutValidationConfiguration): void; } -interface KnockoutSubscribableFunctions { +interface KnockoutSubscribableFunctions { isValid: KnockoutComputed; isValidating: KnockoutObservable; rules: KnockoutObservableArray; diff --git a/knockout/tests/knockout-tests.ts b/knockout/tests/knockout-tests.ts index e74012548..1ebef13ef 100644 --- a/knockout/tests/knockout-tests.ts +++ b/knockout/tests/knockout-tests.ts @@ -38,7 +38,7 @@ function test_computed() { this.firstName = ko.observable('Planet'); this.lastName = ko.observable('Earth'); - this.fullName = ko.computed({ + this.fullName = ko.computed({ read: function () { return this.firstName() + " " + this.lastName(); }, @@ -257,7 +257,7 @@ interface KnockoutExtenders { required(target, overrideMessage); } -interface KnockoutObservableArrayFunctions { +interface KnockoutObservableArrayFunctions { filterByProperty(propName, matchValue): KnockoutComputed; } @@ -491,7 +491,7 @@ function test_mappingplugin() { } // Define your own functions -interface KnockoutSubscribableFunctions { +interface KnockoutSubscribableFunctions { publishOn(topic: string): any; subscribeTo(topic: string): any; } diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 0afd19370..b48f7e603 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -321,7 +321,7 @@ declare module _ { /** * @see _.findIndex **/ - findIndex( + findIndex( array: List, whereDictionary: W): number; } @@ -404,7 +404,7 @@ declare module _ { * @see _.first * @param whereValue "_.where" style callback value **/ - first( + first( array: List, whereValue: W): T[]; @@ -438,7 +438,7 @@ declare module _ { /** * @see _.first **/ - head( + head( array: List, whereValue: W): T[]; @@ -472,7 +472,7 @@ declare module _ { /** * @see _.first **/ - take( + take( array: List, whereValue: W): T[]; } @@ -507,12 +507,12 @@ declare module _ { callback: ListIterator, thisArg?: any): T[]; - flatten( + flatten( array: List, isShallow: boolean, whereValue: W): T[]; - flatten( + flatten( array: List, whereValue: W): T[]; @@ -548,11 +548,11 @@ declare module _ { flatten( pluckValue: string): LoDashArrayWrapper; - flatten( + flatten( isShallow: boolean, whereValue: W): LoDashArrayWrapper; - flatten( + flatten( whereValue: W): LoDashArrayWrapper; } @@ -638,7 +638,7 @@ declare module _ { * @see _.initial * @param whereValue _.where style callback **/ - initial( + initial( array: List, whereValue: W): T[]; } @@ -700,7 +700,7 @@ declare module _ { * @see _.last * @param whereValue _.where style callback **/ - last( + last( array: List, whereValue: W): T[]; } @@ -848,7 +848,7 @@ declare module _ { /** * @see _.rest **/ - rest( + rest( array: List, whereValue: W): T[]; @@ -882,7 +882,7 @@ declare module _ { /** * @see _.rest **/ - drop( + drop( array: List, whereValue: W): T[]; @@ -916,7 +916,7 @@ declare module _ { /** * @see _.rest **/ - tail( + tail( array: List, whereValue: W): T[]; } @@ -958,7 +958,7 @@ declare module _ { * @see _.sortedIndex * @param pluckValue the _.where style callback **/ - sortedIndex( + sortedIndex( array: List, value: T, whereValue: W): number; @@ -1028,12 +1028,12 @@ declare module _ { * @see _.uniq * @param whereValue _.where style callback **/ - uniq( + uniq( array: List, isSorted: boolean, whereValue: W): T[]; - uniq( + uniq( array: List, whereValue: W): T[]; @@ -1073,11 +1073,11 @@ declare module _ { * @see _.uniq * @param whereValue _.where style callback **/ - unique( + unique( array: List, whereValue?: W): T[]; - unique( + unique( array: List, isSorted: boolean, whereValue?: W): T[]; @@ -1315,7 +1315,7 @@ declare module _ { * @see _.every * @param whereValue _.where style callback **/ - every( + every( collection: Collection, whereValue: W): boolean; @@ -1339,7 +1339,7 @@ declare module _ { * @see _.every * @param whereValue _.where style callback **/ - all( + all( collection: Collection, whereValue: W): boolean; } @@ -1378,7 +1378,7 @@ declare module _ { * @see _.filter * @param pluckValue _.pluck style callback **/ - filter( + filter( collection: Collection, whereValue: W): T[]; @@ -1402,7 +1402,7 @@ declare module _ { * @see _.filter * @param pluckValue _.pluck style callback **/ - select( + select( collection: Collection, whereValue: W): T[]; } @@ -1426,7 +1426,7 @@ declare module _ { * @see _.filter * @param pluckValue _.pluck style callback **/ - filter( + filter( whereValue: W): LoDashArrayWrapper; /** @@ -1447,7 +1447,7 @@ declare module _ { * @see _.filter * @param pluckValue _.pluck style callback **/ - select( + select( whereValue: W): LoDashArrayWrapper; } @@ -1477,7 +1477,7 @@ declare module _ { * @see _.find * @param _.pluck style callback **/ - find( + find( collection: Collection, whereValue: W): T; @@ -1501,7 +1501,7 @@ declare module _ { * @see _.find * @param _.pluck style callback **/ - detect( + detect( collection: Collection, whereValue: W): T; @@ -1525,7 +1525,7 @@ declare module _ { * @see _.find * @param _.pluck style callback **/ - findWhere( + findWhere( collection: Collection, whereValue: W): T; @@ -1557,7 +1557,7 @@ declare module _ { * @see _.find * @param _.pluck style callback **/ - findLast( + findLast( collection: Collection, whereValue: W): T; @@ -1756,12 +1756,12 @@ declare module _ { * @see _.groupBy * @param whereValue _.where style callback **/ - groupBy( + groupBy( collection: List, whereValue: W): Dictionary; } - interface LoDashArrayWrapper { + interface LoDashArrayWrapper { /** * @see _.groupBy **/ @@ -1778,7 +1778,7 @@ declare module _ { /** * @see _.groupBy **/ - groupBy( + groupBy( whereValue: W): _.LoDashObjectWrapper>; } @@ -1817,7 +1817,7 @@ declare module _ { * @see _.indexBy * @param whereValue _.where style callback **/ - indexBy( + indexBy( collection: List, whereValue: W): Dictionary; } @@ -1993,7 +1993,7 @@ declare module _ { * @see _.max * @param whereValue _.where style callback **/ - max( + max( collection: Collection, whereValue: W): T; } @@ -2033,7 +2033,7 @@ declare module _ { * @see _.min * @param whereValue _.where style callback **/ - min( + min( collection: Collection, whereValue: W): T; } @@ -2190,7 +2190,7 @@ declare module _ { * @see _.reject * @param whereValue _.where style callback **/ - reject( + reject( collection: Collection, whereValue: W): T[]; } @@ -2281,7 +2281,7 @@ declare module _ { * @see _.some * @param whereValue _.where style callback **/ - some( + some( collection: Collection, whereValue: W): boolean; @@ -2305,7 +2305,7 @@ declare module _ { * @see _.some * @param whereValue _.where style callback **/ - any( + any( collection: Collection, whereValue: W): boolean; } @@ -2345,7 +2345,7 @@ declare module _ { * @see _.sortBy * @param whereValue _.where style callback **/ - sortBy( + sortBy( collection: List, whereValue: W): T[]; } @@ -2784,7 +2784,7 @@ declare module _ { * @param thisArg The this binding of callback. * @return The destination object. **/ - assign( + assign( object: T, s1: S1, callback?: (objectValue: Value, sourceValue: Value) => Value, @@ -2793,7 +2793,7 @@ declare module _ { /** * @see _.assign **/ - assign( + assign( object: T, s1: S1, s2: S2, @@ -2803,7 +2803,7 @@ declare module _ { /** * @see _.assign **/ - assign( + assign( object: T, s1: S1, s2: S2, @@ -2814,7 +2814,7 @@ declare module _ { /** * @see _.assign **/ - assign( + assign( object: T, s1: S1, s2: S2, @@ -2826,7 +2826,7 @@ declare module _ { /** * @see _.assign **/ - extend( + extend( object: T, s1: S1, callback?: (objectValue: Value, sourceValue: Value) => Value, @@ -2835,7 +2835,7 @@ declare module _ { /** * @see _.assign **/ - extend( + extend( object: T, s1: S1, s2: S2, @@ -2845,7 +2845,7 @@ declare module _ { /** * @see _.assign **/ - extend( + extend( object: T, s1: S1, s2: S2, @@ -2856,7 +2856,7 @@ declare module _ { /** * @see _.assign **/ - extend( + extend( object: T, s1: S1, s2: S2, @@ -3054,7 +3054,7 @@ declare module _ { * @see _.findKey * @param whereValue _.where style callback **/ - findKey, T extends W>( + findKey, T>( object: T, whereValue: W): string; } @@ -3085,7 +3085,7 @@ declare module _ { * @see _.findLastKey * @param whereValue _.where style callback **/ - findLastKey, T extends W>( + findLastKey, T>( object: T, whereValue: W): string; } @@ -3107,7 +3107,7 @@ declare module _ { thisArg?: any): Dictionary; } - interface LoDashObjectWrapper { + interface LoDashObjectWrapper { /** * @see _.forIn **/ @@ -3132,7 +3132,7 @@ declare module _ { thisArg?: any): Dictionary; } - interface LoDashObjectWrapper { + interface LoDashObjectWrapper { /** * @see _.forInRight **/ @@ -3158,7 +3158,7 @@ declare module _ { thisArg?: any): Dictionary; } - interface LoDashObjectWrapper { + interface LoDashObjectWrapper { /** * @see _.forOwn **/ @@ -3183,7 +3183,7 @@ declare module _ { thisArg?: any): Dictionary; } - interface LoDashObjectWrapper { + interface LoDashObjectWrapper { /** * @see _.forOwnRight **/ @@ -3208,7 +3208,7 @@ declare module _ { methods(object: any): string[]; } - interface LoDashObjectWrapper { + interface LoDashObjectWrapper { /** * @see _.functions **/ @@ -3472,7 +3472,7 @@ declare module _ { * @param thisArg The this binding of callback. * @return The destination object. **/ - merge( + merge( object: T, s1: S1, callback?: (objectValue: Value, sourceValue: Value) => Value, @@ -3481,7 +3481,7 @@ declare module _ { /** * @see _.merge **/ - merge( + merge( object: T, s1: S1, s2: S2, @@ -3491,7 +3491,7 @@ declare module _ { /** * @see _.merge **/ - merge( + merge( object: T, s1: S1, s2: S2, @@ -3502,7 +3502,7 @@ declare module _ { /** * @see _.merge **/ - merge( + merge( object: T, s1: S1, s2: S2, @@ -3524,21 +3524,21 @@ declare module _ { * @param keys The properties to omit. * @return An object without the omitted properties. **/ - omit( + omit( object: T, ...keys: string[]): Omitted; /** * @see _.omit **/ - omit( + omit( object: T, keys: string[]): Omitted; /** * @see _.omit **/ - omit( + omit( object: T, callback: ObjectIterator, thisArg?: any): Omitted; @@ -3567,21 +3567,21 @@ declare module _ { * @param keys Property names to pick * @return An object composed of the picked properties. **/ - pick( + pick( object: T, ...keys: string[]): Picked; /** * @see _.pick **/ - pick( + pick( object: T, keys: string[]): Picked; /** * @see _.pick **/ - pick( + pick( object: T, callback: ObjectIterator, thisArg?: any): Picked; diff --git a/node/node.d.ts b/node/node.d.ts index 8801de5b2..fe7fbd324 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -271,8 +271,11 @@ declare module "http" { } export interface ServerResponse extends NodeEventEmitter, WritableStream { // Extended base methods - write(str: string, encoding?: string, fd?: string): boolean; write(buffer: NodeBuffer): boolean; + write(buffer: NodeBuffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; writeContinue(): void; writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void; @@ -284,19 +287,34 @@ declare module "http" { removeHeader(name: string): void; write(chunk: any, encoding?: string): any; addTrailers(headers: any): void; + + // Extended base methods + end(): void; + end(buffer: NodeBuffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; end(data?: any, encoding?: string): void; } export interface ClientRequest extends NodeEventEmitter, WritableStream { // Extended base methods - write(str: string, encoding?: string, fd?: string): boolean; write(buffer: NodeBuffer): boolean; + write(buffer: NodeBuffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; write(chunk: any, encoding?: string): void; - end(data?: any, encoding?: string): void; abort(): void; setTimeout(timeout: number, callback?: Function): void; setNoDelay(noDelay?: Function): void; setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; + + // Extended base methods + end(): void; + end(buffer: NodeBuffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + end(data?: any, encoding?: string): void; } export interface ClientResponse extends NodeEventEmitter, ReadableStream { statusCode: number; @@ -653,15 +671,17 @@ declare module "net" { export interface NodeSocket extends ReadWriteStream { // Extended base methods - write(str: string, encoding?: string, fd?: string): boolean; write(buffer: NodeBuffer): boolean; + write(buffer: NodeBuffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; connect(port: number, host?: string, connectionListener?: Function): void; connect(path: string, connectionListener?: Function): void; bufferSize: number; setEncoding(encoding?: string): void; write(data: any, encoding?: string, callback?: Function): void; - end(data?: any, encoding?: string): void; destroy(): void; pause(): void; resume(): void; @@ -673,6 +693,13 @@ declare module "net" { remotePort: number; bytesRead: number; bytesWritten: number; + + // Extended base methods + end(): void; + end(buffer: NodeBuffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + end(data?: any, encoding?: string): void; } export var Socket: { diff --git a/package.json b/package.json index 382b060bd..0119109e9 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,6 @@ "name": "DefinitelyTyped", "version": "0.0.0", "scripts": { - "test": "node ./_infrastructure/tests/runner.js --tsc-version 0.9.5" + "test": "node ./_infrastructure/tests/runner.js --tsc-version 0.9.7" } } diff --git a/pixi/webgl.d.ts b/pixi/webgl.d.ts index 71538bbf8..ebf1204dc 100644 --- a/pixi/webgl.d.ts +++ b/pixi/webgl.d.ts @@ -3,14 +3,6 @@ // Definitions by: xperiments // Definitions: https://github.com/borisyankov/DefinitelyTyped -interface WebGLContextAttributes { - alpha : boolean; - depth : boolean; - stencil : boolean; - antialias : boolean; - premultipliedAlpha : boolean; -} - interface WebGLObject { $__dummyprop__WebGLObject : any; } @@ -43,314 +35,11 @@ interface WebGLUniformLocation { $__dummyprop__WebGLUniformLocation : any; } -interface WebGLActiveInfo { - size : number; - type : number; - name : string; -} - interface WebGLRenderingContext { - DEPTH_BUFFER_BIT : number; - STENCIL_BUFFER_BIT : number; - COLOR_BUFFER_BIT : number; - POINTS : number; - LINES : number; - LINE_LOOP : number; - LINE_STRIP : number; - TRIANGLES : number; - TRIANGLE_STRIP : number; - TRIANGLE_FAN : number; - ZERO : number; - ONE : number; - SRC_COLOR : number; - ONE_MINUS_SRC_COLOR : number; - SRC_ALPHA : number; - ONE_MINUS_SRC_ALPHA : number; - DST_ALPHA : number; - ONE_MINUS_DST_ALPHA : number; - DST_COLOR : number; - ONE_MINUS_DST_COLOR : number; - SRC_ALPHA_SATURATE : number; - FUNC_ADD : number; - BLEND_EQUATION : number; - BLEND_EQUATION_RGB : number; - BLEND_EQUATION_ALPHA : number; - FUNC_SUBTRACT : number; - FUNC_REVERSE_SUBTRACT : number; - BLEND_DST_RGB : number; - BLEND_SRC_RGB : number; - BLEND_DST_ALPHA : number; - BLEND_SRC_ALPHA : number; - CONSTANT_COLOR : number; - ONE_MINUS_CONSTANT_COLOR : number; - CONSTANT_ALPHA : number; - ONE_MINUS_CONSTANT_ALPHA : number; - BLEND_COLOR : number; - ARRAY_BUFFER : number; - ELEMENT_ARRAY_BUFFER : number; - ARRAY_BUFFER_BINDING : number; - ELEMENT_ARRAY_BUFFER_BINDING : number; - STREAM_DRAW : number; - STATIC_DRAW : number; - DYNAMIC_DRAW : number; - BUFFER_SIZE : number; - BUFFER_USAGE : number; - CURRENT_VERTEX_ATTRIB : number; - FRONT : number; - BACK : number; - FRONT_AND_BACK : number; - TEXTURE_2D : number; - CULL_FACE : number; - BLEND : number; - DITHER : number; - STENCIL_TEST : number; - DEPTH_TEST : number; - SCISSOR_TEST : number; - POLYGON_OFFSET_FILL : number; - SAMPLE_ALPHA_TO_COVERAGE : number; - SAMPLE_COVERAGE : number; - NO_ERROR : number; - INVALID_ENUM : number; - INVALID_VALUE : number; - INVALID_OPERATION : number; - OUT_OF_MEMORY : number; - CW : number; - CCW : number; - LINE_WIDTH : number; - ALIASED_POINT_SIZE_RANGE : number; - ALIASED_LINE_WIDTH_RANGE : number; - CULL_FACE_MODE : number; - FRONT_FACE : number; - DEPTH_RANGE : number; - DEPTH_WRITEMASK : number; - DEPTH_CLEAR_VALUE : number; - DEPTH_FUNC : number; - STENCIL_CLEAR_VALUE : number; - STENCIL_FUNC : number; - STENCIL_FAIL : number; - STENCIL_PASS_DEPTH_FAIL : number; - STENCIL_PASS_DEPTH_PASS : number; - STENCIL_REF : number; - STENCIL_VALUE_MASK : number; - STENCIL_WRITEMASK : number; - STENCIL_BACK_FUNC : number; - STENCIL_BACK_FAIL : number; - STENCIL_BACK_PASS_DEPTH_FAIL : number; - STENCIL_BACK_PASS_DEPTH_PASS : number; - STENCIL_BACK_REF : number; - STENCIL_BACK_VALUE_MASK : number; - STENCIL_BACK_WRITEMASK : number; - VIEWPORT : number; - SCISSOR_BOX : number; - COLOR_CLEAR_VALUE : number; - COLOR_WRITEMASK : number; - UNPACK_ALIGNMENT : number; - PACK_ALIGNMENT : number; - MAX_TEXTURE_SIZE : number; - MAX_VIEWPORT_DIMS : number; - SUBPIXEL_BITS : number; - RED_BITS : number; - GREEN_BITS : number; - BLUE_BITS : number; - ALPHA_BITS : number; - DEPTH_BITS : number; - STENCIL_BITS : number; - POLYGON_OFFSET_UNITS : number; - POLYGON_OFFSET_FACTOR : number; - TEXTURE_BINDING_2D : number; - SAMPLE_BUFFERS : number; - SAMPLES : number; - SAMPLE_COVERAGE_VALUE : number; - SAMPLE_COVERAGE_INVERT : number; NUM_COMPRESSED_TEXTURE_FORMATS : number; - COMPRESSED_TEXTURE_FORMATS : number; - DONT_CARE : number; - FASTEST : number; - NICEST : number; - GENERATE_MIPMAP_HINT : number; - BYTE : number; - UNSIGNED_BYTE : number; - SHORT : number; - UNSIGNED_SHORT : number; - INT : number; - UNSIGNED_INT : number; - FLOAT : number; - DEPTH_COMPONENT : number; - ALPHA : number; - RGB : number; - RGBA : number; - LUMINANCE : number; - LUMINANCE_ALPHA : number; - UNSIGNED_SHORT_4_4_4_4 : number; - UNSIGNED_SHORT_5_5_5_1 : number; - UNSIGNED_SHORT_5_6_5 : number; - FRAGMENT_SHADER : number; - VERTEX_SHADER : number; - MAX_VERTEX_ATTRIBS : number; - MAX_VERTEX_UNIFORM_VECTORS : number; - MAX_VARYING_VECTORS : number; - MAX_COMBINED_TEXTURE_IMAGE_UNITS : number; - MAX_VERTEX_TEXTURE_IMAGE_UNITS : number; - MAX_TEXTURE_IMAGE_UNITS : number; - MAX_FRAGMENT_UNIFORM_VECTORS : number; - SHADER_TYPE : number; - DELETE_STATUS : number; - LINK_STATUS : number; - VALIDATE_STATUS : number; - ATTACHED_SHADERS : number; - ACTIVE_UNIFORMS : number; ACTIVE_UNIFORM_MAX_LENGTH : number; - ACTIVE_ATTRIBUTES : number; - ACTIVE_ATTRIBUTE_MAX_LENGTH : number; - SHADING_LANGUAGE_VERSION : number; - CURRENT_PROGRAM : number; - NEVER : number; - LESS : number; - EQUAL : number; - LEQUAL : number; - GREATER : number; - NOTEQUAL : number; - GEQUAL : number; - ALWAYS : number; - KEEP : number; - REPLACE : number; - INCR : number; - DECR : number; - INVERT : number; - INCR_WRAP : number; - DECR_WRAP : number; - VENDOR : number; - RENDERER : number; - VERSION : number; - NEAREST : number; - LINEAR : number; - NEAREST_MIPMAP_NEAREST : number; - LINEAR_MIPMAP_NEAREST : number; - NEAREST_MIPMAP_LINEAR : number; - LINEAR_MIPMAP_LINEAR : number; - TEXTURE_MAG_FILTER : number; - TEXTURE_MIN_FILTER : number; - TEXTURE_WRAP_S : number; - TEXTURE_WRAP_T : number; - TEXTURE : number; - TEXTURE_CUBE_MAP : number; - TEXTURE_BINDING_CUBE_MAP : number; - TEXTURE_CUBE_MAP_POSITIVE_X : number; - TEXTURE_CUBE_MAP_NEGATIVE_X : number; - TEXTURE_CUBE_MAP_POSITIVE_Y : number; - TEXTURE_CUBE_MAP_NEGATIVE_Y : number; - TEXTURE_CUBE_MAP_POSITIVE_Z : number; - TEXTURE_CUBE_MAP_NEGATIVE_Z : number; - MAX_CUBE_MAP_TEXTURE_SIZE : number; - TEXTURE0 : number; - TEXTURE1 : number; - TEXTURE2 : number; - TEXTURE3 : number; - TEXTURE4 : number; - TEXTURE5 : number; - TEXTURE6 : number; - TEXTURE7 : number; - TEXTURE8 : number; - TEXTURE9 : number; - TEXTURE10 : number; - TEXTURE11 : number; - TEXTURE12 : number; - TEXTURE13 : number; - TEXTURE14 : number; - TEXTURE15 : number; - TEXTURE16 : number; - TEXTURE17 : number; - TEXTURE18 : number; - TEXTURE19 : number; - TEXTURE20 : number; - TEXTURE21 : number; - TEXTURE22 : number; - TEXTURE23 : number; - TEXTURE24 : number; - TEXTURE25 : number; - TEXTURE26 : number; - TEXTURE27 : number; - TEXTURE28 : number; - TEXTURE29 : number; - TEXTURE30 : number; - TEXTURE31 : number; - ACTIVE_TEXTURE : number; - REPEAT : number; - CLAMP_TO_EDGE : number; - MIRRORED_REPEAT : number; - FLOAT_VEC2 : number; - FLOAT_VEC3 : number; - FLOAT_VEC4 : number; - INT_VEC2 : number; - INT_VEC3 : number; - INT_VEC4 : number; - BOOL : number; - BOOL_VEC2 : number; - BOOL_VEC3 : number; - BOOL_VEC4 : number; - FLOAT_MAT2 : number; - FLOAT_MAT3 : number; - FLOAT_MAT4 : number; - SAMPLER_2D : number; - SAMPLER_CUBE : number; - VERTEX_ATTRIB_ARRAY_ENABLED : number; - VERTEX_ATTRIB_ARRAY_SIZE : number; - VERTEX_ATTRIB_ARRAY_STRIDE : number; - VERTEX_ATTRIB_ARRAY_TYPE : number; - VERTEX_ATTRIB_ARRAY_NORMALIZED : number; - VERTEX_ATTRIB_ARRAY_POINTER : number; - VERTEX_ATTRIB_ARRAY_BUFFER_BINDING : number; - COMPILE_STATUS : number; INFO_LOG_LENGTH : number; SHADER_SOURCE_LENGTH : number; - LOW_FLOAT : number; - MEDIUM_FLOAT : number; - HIGH_FLOAT : number; - LOW_INT : number; - MEDIUM_INT : number; - HIGH_INT : number; - FRAMEBUFFER : number; - RENDERBUFFER : number; - RGBA4 : number; - RGB5_A1 : number; - RGB565 : number; - DEPTH_COMPONENT16 : number; - STENCIL_INDEX : number; - STENCIL_INDEX8 : number; - DEPTH_STENCIL : number; - RENDERBUFFER_WIDTH : number; - RENDERBUFFER_HEIGHT : number; - RENDERBUFFER_INTERNAL_FORMAT : number; - RENDERBUFFER_RED_SIZE : number; - RENDERBUFFER_GREEN_SIZE : number; - RENDERBUFFER_BLUE_SIZE : number; - RENDERBUFFER_ALPHA_SIZE : number; - RENDERBUFFER_DEPTH_SIZE : number; - RENDERBUFFER_STENCIL_SIZE : number; - FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE : number; - FRAMEBUFFER_ATTACHMENT_OBJECT_NAME : number; - FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL : number; - FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE : number; - COLOR_ATTACHMENT0 : number; - DEPTH_ATTACHMENT : number; - STENCIL_ATTACHMENT : number; - DEPTH_STENCIL_ATTACHMENT : number; - NONE : number; - FRAMEBUFFER_COMPLETE : number; - FRAMEBUFFER_INCOMPLETE_ATTACHMENT : number; - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT : number; - FRAMEBUFFER_INCOMPLETE_DIMENSIONS : number; - FRAMEBUFFER_UNSUPPORTED : number; - FRAMEBUFFER_BINDING : number; - RENDERBUFFER_BINDING : number; - MAX_RENDERBUFFER_SIZE : number; - INVALID_FRAMEBUFFER_OPERATION : number; - UNPACK_FLIP_Y_WEBGL : number; - UNPACK_PREMULTIPLY_ALPHA_WEBGL : number; - CONTEXT_LOST_WEBGL : number; - UNPACK_COLORSPACE_CONVERSION_WEBGL : number; - BROWSER_DEFAULT_WEBGL : number; - canvas : HTMLCanvasElement; getContextAttributes() : WebGLContextAttributes; isContextLost() : boolean; getSupportedExtensions() : string[]; @@ -513,7 +202,6 @@ interface WebGLRenderingContext { } interface WebGLContextEvent extends Event { - statusMessage : string; initWebGLContextEvent(typeArg : string, canBubbleArg : boolean, cancelableArg : boolean, statusMessageArg : string) : void; } diff --git a/q-io/Q-io.d.ts b/q-io/Q-io.d.ts index 9f8150046..cbe37214e 100644 --- a/q-io/Q-io.d.ts +++ b/q-io/Q-io.d.ts @@ -177,7 +177,7 @@ declare module QioHTTP { } interface Headers { [name:string]:any; - [name:string]:any[]; + // [name:string]:any[]; } interface Body extends Qio.Stream { diff --git a/rx.js/rx.async-tests.ts b/rx.js/rx.async-tests.ts index 636aa30de..b71f8bd77 100644 --- a/rx.js/rx.async-tests.ts +++ b/rx.js/rx.async-tests.ts @@ -18,9 +18,9 @@ module Rx.Tests.Async { function toAsync() { obsNum = Rx.Observable.toAsync(()=> 1, sch)(); obsNum = Rx.Observable.toAsync((a1: number)=> a1)(1); - obsStr = Rx.Observable.toAsync((a1: string, a2: number)=> a1 + a2.toFixed(0))("", 1); - obsStr = Rx.Observable.toAsync((a1: string, a2: number, a3: Date)=> a1 + a2.toFixed(0) + a3.toDateString())("", 1, new Date()); - obsStr = Rx.Observable.toAsync((a1: string, a2: number, a3: Date, a4: boolean)=> a1 + a2.toFixed(0) + a3.toDateString() + (a4 ? 1 : 0))("", 1, new Date(), false); + obsStr = Rx.Observable.toAsync((a1: string, a2: number)=> a1 + a2.toFixed(0))("", 1); + obsStr = Rx.Observable.toAsync((a1: string, a2: number, a3: Date)=> a1 + a2.toFixed(0) + a3.toDateString())("", 1, new Date()); + obsStr = Rx.Observable.toAsync((a1: string, a2: number, a3: Date, a4: boolean)=> a1 + a2.toFixed(0) + a3.toDateString() + (a4 ? 1 : 0))("", 1, new Date(), false); } function fromCallback() { diff --git a/selenium-webdriver/selenium-webdriver-tests.ts b/selenium-webdriver/selenium-webdriver-tests.ts index 26913f0db..52b317d96 100644 --- a/selenium-webdriver/selenium-webdriver-tests.ts +++ b/selenium-webdriver/selenium-webdriver-tests.ts @@ -7,7 +7,7 @@ function TestAbstractBuilder() { url = builder.getServerUrl(); var otherBuilder: webdriver.AbstractBuilder = builder.usingServer(url); otherBuilder = builder.withCapabilities(webdriver.Capabilities.android()); - var objCapabilities = {}; + var objCapabilities: { [index: string]: string; } = {}; objCapabilities[webdriver.Capability.BROWSER_NAME] = webdriver.Browser.PHANTOM_JS; otherBuilder = builder.withCapabilities(objCapabilities); var url: string = webdriver.AbstractBuilder.DEFAULT_SERVER_URL; diff --git a/sugar/sugar.d.ts b/sugar/sugar.d.ts index e5f9c97d7..de418b65e 100644 --- a/sugar/sugar.d.ts +++ b/sugar/sugar.d.ts @@ -2569,7 +2569,7 @@ interface Array { /** * @see max **/ - max(map: (n: T) => U): T[]; + max(map: (n: T) => U, all: boolean): T[]; /*** * Returns the element in the array with the lowest value. diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index 7b5ee0504..d3eb87f6a 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -16,14 +16,14 @@ var list = [[0, 1], [2, 3], [4, 5]]; //var flat = _.reduceRight(list, (a, b) => a.concat(b), []); // https://typescript.codeplex.com/workitem/1960 var flat = _.reduceRight(list, (a, b) => a.concat(b), []); -var even = _.find([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); +var even = _.find([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); -var evens = _.filter([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); +var evens = _.filter([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); var listOfPlays = [{ title: "Cymbeline", author: "Shakespeare", year: 1611 }, { title: "The Tempest", author: "Shakespeare", year: 1611 }, { title: "Other", author: "Not Shakespeare", year: 2012 }]; _.where(listOfPlays, { author: "Shakespeare", year: 1611 }); -var odds = _.reject([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); +var odds = _.reject([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); //_.every([true, 1, null, 'yes'], _.identity); // https://typescript.codeplex.com/workitem/1960 _.every([true, 1, null, 'yes'], _.identity); @@ -38,7 +38,7 @@ _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); var stooges = [{ name: 'moe', age: 40 }, { name: 'larry', age: 50 }, { name: 'curly', age: 60 }]; _.pluck(stooges, 'name'); -_.max(stooges, (stooge) => stooge.age); +_.max<{ name: string; age: number }>(stooges, (stooge) => stooge.age); _.max([1, 2, 3, 4, 5]);